PR tree-optimization/86415 - strlen() not folded for substrings within constant arrays
[official-gcc.git] / gcc / testsuite / gfortran.dg / char_length_7.f90
blob3d16235e6352c937f486cd713c4c2d345320b1a2
1 ! { dg-do run }
2 ! Test the fix for PR31879 in which the concatenation operators below
3 ! would cause ICEs because the character lengths were never resolved.
5 ! Contributed by Vivek Rao <vivekrao4@yahoo.com>
7 module str_mod
8 character(3) :: mz(2) = (/"fgh","ijk"/)
9 contains
10 function ccopy(yy) result(xy)
11 character (len=*), intent(in) :: yy(:)
12 character (len=5) :: xy(size(yy))
13 xy = yy
14 end function ccopy
15 end module str_mod
17 program xx
18 use str_mod, only: ccopy, mz
19 implicit none
20 character(2) :: z = "zz"
21 character(3) :: zz(2) = (/"abc","cde"/)
22 character(2) :: ans(2)
23 integer :: i = 2, j = 3
24 if (any(ccopy("_&_"//(/"A","B"/)//"?") .ne. (/"_&_A?","_&_B?"/))) STOP 1
25 if (any(ccopy(z//zz) .ne. (/"zzabc","zzcde"/))) STOP 2
26 if (any(ccopy(z//zz(:)(1:2)) .ne. (/"zzab ","zzcd "/))) STOP 3
27 if (any(ccopy(z//mz(:)(2:3)) .ne. (/"zzgh ","zzjk "/))) STOP 4
29 ! This was another bug, uncovered when the PR was fixed.
30 if (any(ccopy(z//mz(:)(i:j)) .ne. (/"zzgh ","zzjk "/))) STOP 5
31 end program xx