aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/deferred_character_11.f90
blob: 454cf47e1b138b64584629eacd6c4398d168beb7 (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
38
39
! { dg-do run }
!
! Test the fix for PR61147.
!
! Contributed by Thomas Clune  <Thomas.L.Clune@nasa.gov>
!
module B_mod

   type :: B
      character(:), allocatable :: string
   end type B

contains

   function toPointer(this) result(ptr)
      character(:), pointer :: ptr
      class (B), intent(in), target :: this

         ptr => this%string

   end function toPointer

end module B_mod

program main
   use B_mod

   type (B) :: obj
   character(:), pointer :: p

   obj%string = 'foo'
   p => toPointer(obj)

   If (len (p) .ne. 3) call abort
   If (p .ne. "foo") call abort

end program main