aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/deferred_character_11.f90
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gfortran.dg/deferred_character_11.f90')
-rw-r--r--gcc/testsuite/gfortran.dg/deferred_character_11.f9039
1 files changed, 39 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.dg/deferred_character_11.f90 b/gcc/testsuite/gfortran.dg/deferred_character_11.f90
new file mode 100644
index 00000000000..454cf47e1b1
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/deferred_character_11.f90
@@ -0,0 +1,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
+
+