2 ! Tests fix for PR41600 and further SELECT TYPE functionality.
4 ! Reported by Tobias Burnus <burnus@gcc.gnu.org>
11 type, extends(t0) :: t1
17 class(t0), allocatable :: foo(:)
22 class(t0), allocatable :: foo
26 type(t_scalar) :: m1(4)
29 ! Test the fix for PR41600 itself - first with m%foo of declared type.
30 allocate(m%foo(3), source = [(t0(n), n = 1,3)])
31 select type(bar => m%foo)
33 if (any (bar%j .ne. [1,2,3])) call abort
39 allocate(m%foo(3), source = [(t1(n, n*10), n = 4,6)])
41 ! Then with m%foo of another dynamic type.
42 select type(bar => m%foo)
46 if (any (bar%k .ne. [40,50,60])) call abort
49 ! Try it with a selector array section.
50 select type(bar => m%foo(2:3))
54 if (any (bar%k .ne. [50,60])) call abort
57 ! Try it with a selector array element.
58 select type(bar => m%foo(2))
62 if (bar%k .ne. 50) call abort
65 ! Now try class is and a selector which is an array section of an associate name.
66 select type(bar => m%foo)
70 if (any (bar%j .ne. [4,5,6])) call abort
71 select type (foobar => bar(3:2:-1))
73 if (any (foobar%k .ne. [60,50])) call abort
77 ! Now try class is and a selector which is an array element of an associate name.
78 select type(bar => m%foo)
82 if (any (bar%j .ne. [4,5,6])) call abort
83 select type (foobar => bar(2))
85 if (foobar%k .ne. 50) call abort
89 ! Check class a component of an element of an array. Note that an array of such
90 ! objects cannot be allowed since the elements could have different dynamic types.
93 allocate(m1(n)%foo, source = t1(n*99, n*999))
96 allocate(m1(n)%foo, source = t0(n*99))
98 select type(bar => m1(3)%foo)
100 if (bar%j .ne. 297) call abort
104 select type(bar => m1(1)%foo)
108 if (bar%k .ne. 999) call abort