| 1 |
! { dg-do compile } |
| 2 |
! { dg-options "-ffrontend-optimize -fdump-tree-original" } |
| 3 |
! PR fortran/52537 - optimize comparisons with empty strings |
| 4 |
program main |
| 5 |
implicit none |
| 6 |
character(len=10) :: a |
| 7 |
character(len=30) :: line |
| 8 |
character(len=4,kind=4) :: c4 |
| 9 |
line = 'x' |
| 10 |
read (unit=line,fmt='(A)') a |
| 11 |
c4 = 4_'foo' |
| 12 |
if (c4 == 4_' ') print *,"foobar" |
| 13 |
if (trim(a) == '') print *,"empty" |
| 14 |
call foo(a) |
| 15 |
if (trim(a) == ' ') print *,"empty" |
| 16 |
contains |
| 17 |
subroutine foo(b) |
| 18 |
character(*) :: b |
| 19 |
if (b /= ' ') print *,"full" |
| 20 |
end subroutine foo |
| 21 |
end program main |
| 22 |
! { dg-final { scan-tree-dump-times "_gfortran_string_len_trim" 4 "original" } } |