PR tree-optimization/86415 - strlen() not folded for substrings within constant arrays
[official-gcc.git] / gcc / testsuite / gfortran.dg / deferred_character_11.f90
blob2b040abee2ff82de3a788e62f9ce8d8f48c2f45c
1 ! { dg-do run }
3 ! Test the fix for PR61147.
5 ! Contributed by Thomas Clune <Thomas.L.Clune@nasa.gov>
7 module B_mod
9 type :: B
10 character(:), allocatable :: string
11 end type B
13 contains
15 function toPointer(this) result(ptr)
16 character(:), pointer :: ptr
17 class (B), intent(in), target :: this
19 ptr => this%string
21 end function toPointer
23 end module B_mod
25 program main
26 use B_mod
28 type (B) :: obj
29 character(:), pointer :: p
31 obj%string = 'foo'
32 p => toPointer(obj)
34 If (len (p) .ne. 3) STOP 1
35 If (p .ne. "foo") STOP 2
37 end program main