modula2: Simplify REAL/LONGREAL/SHORTREAL node creation.
[official-gcc.git] / gcc / testsuite / gfortran.dg / trim_optimize_2.f90
blobc90d69f462c66ea5e02a7ea8cb8ee80b47faea46
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') STOP 1
14 if (c /= 'abc') STOP 2
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') STOP 3
31 if (c /= 'abc') STOP 4
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" } }