2 ! PR51870 - ALLOCATE with class function expression for SOURCE failed.
3 ! This version of the test allocates class arrays with MOLD.
5 ! Reported by Tobias Burnus <burnus@gcc.gnu.org>
7 module show_producer_class
10 integer :: variable = 1
15 procedure ,nopass :: create_show
16 procedure ,nopass :: create_show_array
19 function create_show () result(new_integrand)
20 class(integrand) ,allocatable :: new_integrand
21 allocate(new_integrand)
22 new_integrand%variable = -1
24 function create_show_array (n) result(new_integrand)
25 class(integrand) ,allocatable :: new_integrand(:)
27 allocate(new_integrand(n))
28 select type (new_integrand)
29 type is (integrand); new_integrand%variable = [(i, i= 1, n)]
35 use show_producer_class
37 class(integrand) ,allocatable :: kernel1(:), kernel2(:)
38 type(show_producer) :: executive_producer
40 allocate(kernel1(5), kernel2(5),mold=executive_producer%create_show_array (5))
42 type is (integrand); if (any (kernel1%variable .ne. 1)) STOP 1
47 allocate(kernel1(3),mold=executive_producer%create_show ())
49 type is (integrand); if (any (kernel1%variable .ne. 1)) STOP 2
55 type is (integrand); kernel2%variable = [1,2,3,4,5]
58 allocate(kernel1(3),source = kernel2(3:5))
60 type is (integrand); if (any (kernel1%variable .ne. [3,4,5])) STOP 3