summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/trim_optimize_2.f90
blob: b7ae1e3e533025f15d6a62257a846f9e8a4c7a84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
! { dg-do run }
! { dg-options "-O -fdump-tree-original" }
! Optimize unnecessary TRIMs in contained namespaces too.
module faz
  implicit none
contains
  subroutine bar
    character(len=3) :: a
    character(len=4) :: b,c
    b = 'abcd'
    a = trim(b)
    c = trim(trim(a))
    if (a /= 'abc') call abort
    if (c /= 'abc') call abort
  end subroutine bar
end module faz

program main
  use faz
  implicit none
  call foo
  call bar
contains
  subroutine foo
    character(len=3) :: a
    character(len=4) :: b,c
    b = 'abcd'
    a = trim(b)
    c = trim(trim(a))
    if (a /= 'abc') call abort
    if (c /= 'abc') call abort
  end subroutine foo
end program main

! { dg-final { scan-tree-dump-times "memmove" 4 "original" } }
! { dg-final { scan-tree-dump-times "string_trim" 0 "original" } }
! { dg-final { cleanup-tree-dump "original" } }