aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gfortran.dg/select_type_28.f03
blob: 9cab721449122165874cf10d469f035945778417 (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
! { dg-do compile }
!
! Fix for PR53191
!
  implicit none
  type t0
    integer :: j = 42
  end type t0
  type, extends(t0) :: t1
    integer :: k = 99
  end type t1
  type t
    integer :: i
    class(t0), allocatable :: foo
  end type t
  type(t) :: m(4)
  integer :: n

  do n = 1, 2
    allocate(m(n)%foo, source = t0(n*99))
  end do
  do n = 3, 4
    allocate(m(n)%foo, source = t1(n*99, n*999))
  end do

! An array of objects with ultimate class components cannot be a selector
! since each element could have a different dynamic type. (F2003 C614)

  select type(bar => m%foo) ! { dg-error "part reference with nonzero rank" }
    type is(t0)
      if (any (bar%j .ne. [99, 198, 297, 396])) call abort
    type is(t1)
      call abort
  end select

end