aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gfortran.dg/select_type_6.f03
blob: 3b3c08e2296f0f25a53e9d9b4e6cca9b3583fe75 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
! { dg-do run }
!
! PR 41579: [OOP/Polymorphism] Nesting of SELECT TYPE
!
! Contributed by Tobias Burnus <burnus@gcc.gnu.org>

 type t1
 end type t1

 type, extends(t1) :: t2
  integer :: i
 end type t2

 type, extends(t1) :: t3
  integer :: j
 end type t3

 class(t1), allocatable :: mt2, mt3
 allocate(t2 :: mt2)
 allocate(t3 :: mt3)

 select type (mt2)
 type is(t2)
   mt2%i = 5
   print *,mt2%i
   select type(mt3)
   type is(t3)
     mt3%j = 2*mt2%i
     print *,mt3%j
     if (mt3%j /= 10) call abort()
   class default
     call abort()
   end select
 class default
   call abort()
 end select

end