summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/derived_init_2.f90
diff options
context:
space:
mode:
authoreedelman <eedelman@138bc75d-0d04-0410-961f-82ee72b054a4>2006-08-19 21:05:59 +0000
committereedelman <eedelman@138bc75d-0d04-0410-961f-82ee72b054a4>2006-08-19 21:05:59 +0000
commit46643105f4e70e8b5eb15f973fdfe706b7b6b2f5 (patch)
tree9ffd252da63b015eb650b5b5e804b45dbdf68a64 /gcc/testsuite/gfortran.dg/derived_init_2.f90
parentd6fcf85c999145405018758d4ff039b63844cb19 (diff)
downloadgcc-46643105f4e70e8b5eb15f973fdfe706b7b6b2f5.tar.gz
fortran/
2006-08-19 Erik Edelmann <eedelman@gcc.gnu.org> PR fortran/25217 * resolve.c (resolve_fl_variable): Set a default initializer for derived types with INTENT(OUT) even if 'flag' is true. * trans-expr.c (gfc_conv_function_call): Insert code to reinitialize INTENT(OUT) arguments of derived type with default initializers. testsuite/ 2006-08-19 Erik Edelmann <eedelman@gcc.gnu.org> PR fortran/25217 * gfortran.dg/derived_init_2.f90: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@116261 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gfortran.dg/derived_init_2.f90')
-rw-r--r--gcc/testsuite/gfortran.dg/derived_init_2.f9038
1 files changed, 38 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.dg/derived_init_2.f90 b/gcc/testsuite/gfortran.dg/derived_init_2.f90
new file mode 100644
index 00000000000..381f13afbbc
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/derived_init_2.f90
@@ -0,0 +1,38 @@
+! { dg-do run }
+! PR 25217: INTENT(OUT) dummies of derived type with default initializers shall
+! be (re)initialized upon procedure entry, unless they are ALLOCATABLE.
+program main
+
+ implicit none
+
+ type :: drv
+ integer :: a(3) = [ 1, 2, 3 ]
+ character(3) :: s = "abc"
+ real, pointer :: p => null()
+ end type drv
+ type(drv) :: aa
+ type(drv), allocatable :: ab(:)
+ real, target :: x
+
+ aa%a = [ 4, 5, 6]
+ aa%s = "def"
+ aa%p => x
+ call sub(aa)
+
+ call sub2(ab)
+
+contains
+
+ subroutine sub(fa)
+ type(drv), intent(out) :: fa
+
+ if (any(fa%a /= [ 1, 2, 3 ])) call abort()
+ if (fa%s /= "abc") call abort()
+ if (associated(fa%p)) call abort()
+ end subroutine sub
+
+ subroutine sub2(fa)
+ type(drv), allocatable, intent(out) :: fa(:)
+ end subroutine sub2
+
+end program main