PR target/83368
[official-gcc.git] / gcc / testsuite / gfortran.dg / trim_optimize_2.f90
blob6fe9bd451c0263e578c85d263951c772dd563e6b
1 ! { dg-do run }
2 ! { dg-options "-O -fdump-tree-original" }
3 ! Optimize unnecessary TRIMs in contained namespaces too.
4 module faz
5 implicit none
6 contains
7 subroutine bar
8 character(len=3) :: a
9 character(len=4) :: b,c
10 b = 'abcd'
11 a = trim(b)
12 c = trim(trim(a))
13 if (a /= 'abc') call abort
14 if (c /= 'abc') call abort
15 end subroutine bar
16 end module faz
18 program main
19 use faz
20 implicit none
21 call foo
22 call bar
23 contains
24 subroutine foo
25 character(len=3) :: a
26 character(len=4) :: b,c
27 b = 'abcd'
28 a = trim(b)
29 c = trim(trim(a))
30 if (a /= 'abc') call abort
31 if (c /= 'abc') call abort
32 end subroutine foo
33 end program main
35 ! { dg-final { scan-tree-dump-times "memmove" 6 "original" } }
36 ! { dg-final { scan-tree-dump-times "string_trim" 0 "original" } }