annotate gcc/testsuite/gfortran.dg/class_allocate_10.f03 @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 84e7813d76e9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ! { dg-do run }
kono
parents:
diff changeset
2 ! PR51870 - ALLOCATE with class function expression for SOURCE failed.
kono
parents:
diff changeset
3 ! This version of the test allocates class arrays with MOLD.
kono
parents:
diff changeset
4 !
kono
parents:
diff changeset
5 ! Reported by Tobias Burnus <burnus@gcc.gnu.org>
kono
parents:
diff changeset
6 !
kono
parents:
diff changeset
7 module show_producer_class
kono
parents:
diff changeset
8 implicit none
kono
parents:
diff changeset
9 type integrand
kono
parents:
diff changeset
10 integer :: variable = 1
kono
parents:
diff changeset
11 end type integrand
kono
parents:
diff changeset
12
kono
parents:
diff changeset
13 type show_producer
kono
parents:
diff changeset
14 contains
kono
parents:
diff changeset
15 procedure ,nopass :: create_show
kono
parents:
diff changeset
16 procedure ,nopass :: create_show_array
kono
parents:
diff changeset
17 end type
kono
parents:
diff changeset
18 contains
kono
parents:
diff changeset
19 function create_show () result(new_integrand)
kono
parents:
diff changeset
20 class(integrand) ,allocatable :: new_integrand
kono
parents:
diff changeset
21 allocate(new_integrand)
kono
parents:
diff changeset
22 new_integrand%variable = -1
kono
parents:
diff changeset
23 end function
kono
parents:
diff changeset
24 function create_show_array (n) result(new_integrand)
kono
parents:
diff changeset
25 class(integrand) ,allocatable :: new_integrand(:)
kono
parents:
diff changeset
26 integer :: n, i
kono
parents:
diff changeset
27 allocate(new_integrand(n))
kono
parents:
diff changeset
28 select type (new_integrand)
kono
parents:
diff changeset
29 type is (integrand); new_integrand%variable = [(i, i= 1, n)]
kono
parents:
diff changeset
30 end select
kono
parents:
diff changeset
31 end function
kono
parents:
diff changeset
32 end module
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 program main
kono
parents:
diff changeset
35 use show_producer_class
kono
parents:
diff changeset
36 implicit none
kono
parents:
diff changeset
37 class(integrand) ,allocatable :: kernel1(:), kernel2(:)
kono
parents:
diff changeset
38 type(show_producer) :: executive_producer
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 allocate(kernel1(5), kernel2(5),mold=executive_producer%create_show_array (5))
kono
parents:
diff changeset
41 select type(kernel1)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
42 type is (integrand); if (any (kernel1%variable .ne. 1)) STOP 1
111
kono
parents:
diff changeset
43 end select
kono
parents:
diff changeset
44
kono
parents:
diff changeset
45 deallocate (kernel1)
kono
parents:
diff changeset
46
kono
parents:
diff changeset
47 allocate(kernel1(3),mold=executive_producer%create_show ())
kono
parents:
diff changeset
48 select type(kernel1)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
49 type is (integrand); if (any (kernel1%variable .ne. 1)) STOP 2
111
kono
parents:
diff changeset
50 end select
kono
parents:
diff changeset
51
kono
parents:
diff changeset
52 deallocate (kernel1)
kono
parents:
diff changeset
53
kono
parents:
diff changeset
54 select type(kernel2)
kono
parents:
diff changeset
55 type is (integrand); kernel2%variable = [1,2,3,4,5]
kono
parents:
diff changeset
56 end select
kono
parents:
diff changeset
57
kono
parents:
diff changeset
58 allocate(kernel1(3),source = kernel2(3:5))
kono
parents:
diff changeset
59 select type(kernel1)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
60 type is (integrand); if (any (kernel1%variable .ne. [3,4,5])) STOP 3
111
kono
parents:
diff changeset
61 end select
kono
parents:
diff changeset
62 end program