2017-02-20 Paul Thomas <pault@gcc.gnu.org>
[official-gcc.git] / gcc / testsuite / gfortran.dg / select_type_5.f03
blobec9d3cd8d17f7178f333b02ffdfd5b5acdc34227
1 ! { dg-do run }
3 ! SELECT TYPE with associate-name
5 ! Contributed by Janus Weil <janus@gcc.gnu.org>
7   type :: t1
8     integer :: i = -1
9     class(t1), pointer :: c
10   end type t1
12   type, extends(t1) :: t2
13     integer :: j = -1
14   end type t2
16   type(t2), target :: b
17   integer :: aa
19   b%c => b
20   aa = 5
22   select type (aa => b%c)
23   type is (t1)
24     aa%i = 1
25   type is (t2)
26     aa%j = 2
27   end select
29   print *,b%i,b%j
30   if (b%i /= -1) call abort()
31   if (b%j /= 2) call abort()
33   select type (aa => b%c)
34   type is (t1)
35     aa%i = 4
36   type is (t2)
37     aa%i = 3*aa%j
38   end select
40   print *,b%i,b%j
41   if (b%i /= 6) call abort()
42   if (b%j /= 2) call abort()
44   print *,aa
45   if (aa/=5) call abort()
47 end