summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/select_type_48.f90
blob: d9ad01ce4f605a1a77fda7e799c8d08f1d6f2caf (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
! { dg-do run }
!
! Test the fix for PR92976, in which the TYPE IS statement caused an ICE
! because of the explicit bounds of 'x'.
!
! Contributed by Gerhard Steinmetz  <gscfq@t-online.de>
!
program p
   type t
      integer :: i
   end type
   class(t), allocatable :: c(:)
   allocate (c, source = [t(1111),t(2222),t(3333)])
   call s(c)
   if (sum (c%i) .ne. 3333) stop 1
contains
   subroutine s(x)
      class(t) :: x(2)
      select type (x)
! ICE as compiler attempted to assign descriptor to an array
         type is (t)
            x%i = 0
! Make sure that bounds are correctly translated.
            call counter (x)
      end select
   end
   subroutine counter (arg)
     type(t) :: arg(:)
     if (size (arg, 1) .ne. 2) stop 2
   end
end