PR tree-optimization/86415 - strlen() not folded for substrings within constant arrays
[official-gcc.git] / gcc / testsuite / gfortran.dg / elemental_subroutine_9.f90
blobffdb7d149fb0c8e39c778d391b8f3d83e4f05321
1 ! { dg-do run }
3 ! PR fortran/59906
5 ! Contributed by H Anlauf <anlauf@gmx.de>
7 ! Failed generate character scalar for scalarized loop for elemantal call.
9 program x
10 implicit none
11 call y('bbb')
12 contains
14 subroutine y(str)
15 character(len=*), intent(in) :: str
16 character(len=len_trim(str)) :: str_aux
17 character(len=3) :: str3 = 'abc'
19 str_aux = str
21 ! Compiled but did not give correct result
22 if (any (str_cmp((/'aaa','bbb'/), str) .neqv. [.FALSE.,.TRUE.])) STOP 1
24 ! Did not compile
25 if (any (str_cmp((/'bbb', 'aaa'/), str_aux) .neqv. [.TRUE.,.FALSE.])) STOP 2
27 ! Verify patch
28 if (any (str_cmp((/'bbb', 'aaa'/), str3) .neqv. [.FALSE.,.FALSE.])) STOP 3
29 if (any (str_cmp((/'bbb', 'aaa'/), 'aaa') .neqv. [.FALSE.,.TRUE.])) STOP 4
31 end subroutine y
33 elemental logical function str_cmp(str1, str2)
34 character(len=*), intent(in) :: str1
35 character(len=*), intent(in) :: str2
36 str_cmp = (str1 == str2)
37 end function str_cmp
39 end program x