view gcc/testsuite/gfortran.dg/select_type_6.f03 @ 144:8f4e72ab4e11

fix segmentation fault caused by nothing next cur_op to end
author Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Sun, 23 Dec 2018 21:23:56 +0900
parents 84e7813d76e9
children
line wrap: on
line source

! { 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) STOP 1
   class default
     STOP 2
   end select
 class default
   STOP 3
 end select

end