gcc/fortran/
[official-gcc.git] / gcc / testsuite / gfortran.dg / deferred_character_11.f90
blob454cf47e1b138b64584629eacd6c4398d168beb7
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) call abort
35 If (p .ne. "foo") call abort
37 end program main