Merged trunk at revision 161680 into branch.
[official-gcc.git] / gcc / testsuite / gfortran.dg / allocate_alloc_opt_10.f90
blob5bccefaaf151b4b78f99c083f84f4aacf276ff54
1 ! { dg-do run }
3 ! PR 43388: [F2008][OOP] ALLOCATE with MOLD=
5 ! Contributed by Janus Weil <janus@gcc.gnu.org>
7 type :: t1
8 integer :: i
9 end type
11 type,extends(t1) :: t2
12 integer :: j = 4
13 end type
15 class(t1),allocatable :: x,y
16 type(t2) :: z
19 !!! first example (works)
21 z%j = 5
22 allocate(x,MOLD=z)
24 select type (x)
25 type is (t2)
26 print *,x%j
27 if (x%j/=4) call abort
28 class default
29 call abort()
30 end select
33 !!! second example (fails)
34 !!! FIXME: uncomment once implemented (cf. PR 44541)
36 ! allocate(y,MOLD=x)
38 ! select type (y)
39 ! type is (t2)
40 ! print *,y%j
41 ! if (y%j/=4) call abort
42 ! class default
43 ! call abort()
44 ! end select
46 end