Debian Codegraph @

gcc/testsuite/gfortran.dg/pr114874_1.f90

raw
1 ! { dg-do compile }
2 ! Test fix for regression caused by r14-9489 - valid code only.
3 ! Contributed by Harald Anlauf <[email protected]>
4 !
5 module p
6 implicit none
7 contains
8 subroutine foo
9 class(*), allocatable :: c
10 c = 'abc'
11 select type (c)
12 type is (character(*))
13 if (c .ne. 'abc') stop 1
14 ! Regression caused ICE here - valid substring reference
15 if (c(2:2) .ne. 'b') stop 2
16 end select
17 end
18 subroutine bar ! This worked correctly
19 class(*), allocatable :: c(:)
20 c = ['abc','def']
21 select type (c)
22 type is (character(*))
23 if (any (c .ne. ['abc','def'])) stop 3
24 if (any (c(:)(2:2) .ne. ['b','e'])) stop 4
25 end select
26 end
27 end module p
28
29 use p
30 call foo
31 call bar
32 end