1! { dg-do run } 2! { dg-options "-O -fdump-tree-original" } 3! Optimize unnecessary TRIMs in contained namespaces too. 4module faz 5 implicit none 6contains 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 16end module faz 17 18program main 19 use faz 20 implicit none 21 call foo 22 call bar 23contains 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 33end program main 34 35! { dg-final { scan-tree-dump-times "memmove" 6 "original" } } 36! { dg-final { scan-tree-dump-times "string_trim" 0 "original" } } 37! { dg-final { cleanup-tree-dump "original" } } 38