| 1 |
! { dg-do run } |
| 2 |
! |
| 3 |
! Test the fix for PR61147. |
| 4 |
! |
| 5 |
! Contributed by Thomas Clune <[email protected]> |
| 6 |
! |
| 7 |
module B_mod |
| 8 |
|
| 9 |
type :: B |
| 10 |
character(:), allocatable :: string |
| 11 |
end type B |
| 12 |
|
| 13 |
contains |
| 14 |
|
| 15 |
function toPointer(this) result(ptr) |
| 16 |
character(:), pointer :: ptr |
| 17 |
class (B), intent(in), target :: this |
| 18 |
|
| 19 |
ptr => this%string |
| 20 |
|
| 21 |
end function toPointer |
| 22 |
|
| 23 |
end module B_mod |
| 24 |
|
| 25 |
program main |
| 26 |
use B_mod |
| 27 |
|
| 28 |
type (B) :: obj |
| 29 |
character(:), pointer :: p |
| 30 |
|
| 31 |
obj%string = 'foo' |
| 32 |
p => toPointer(obj) |
| 33 |
|
| 34 |
If (len (p) .ne. 3) STOP 1 |
| 35 |
If (p .ne. "foo") STOP 2 |
| 36 |
|
| 37 |
end program main |
| 38 |
|
| 39 |
|