diff options
Diffstat (limited to 'gcc/testsuite/gfortran.dg/select_type_28.f03')
-rw-r--r-- | gcc/testsuite/gfortran.dg/select_type_28.f03 | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.dg/select_type_28.f03 b/gcc/testsuite/gfortran.dg/select_type_28.f03 new file mode 100644 index 0000000000..9cab721449 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/select_type_28.f03 @@ -0,0 +1,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 |