From cb44ab824bd0902002bbf1caa66c05b56829630c Mon Sep 17 00:00:00 2001 From: Victor Leikehman Date: Sat, 15 May 2004 01:52:04 +0300 Subject: [PATCH] decl.c (variable_decl): Always apply default initializer. fortran/ * decl.c (variable_decl): Always apply default initializer. libgfortran/ * gfortran.fortran-torture/execute/def_init_3.f90: New test. From-SVN: r81865 --- gcc/fortran/ChangeLog | 4 ++++ gcc/fortran/decl.c | 9 +++++---- gcc/testsuite/ChangeLog | 4 ++++ .../gfortran.fortran-torture/execute/der_init_3.f90 | 12 ++++++++++++ 4 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gfortran.fortran-torture/execute/der_init_3.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 605a5726b05..19a66ce588a 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,7 @@ +2004-05-14 Victor Leikehman + + * decl.c (variable_decl): Always apply default initializer. + 2004-05-08 Tobias Schlüter PR fortran/15206 diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 9d6bf948dd7..2aed9b248d6 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -619,10 +619,11 @@ variable_decl (void) if (m != MATCH_YES) goto cleanup; } - else if (current_ts.type == BT_DERIVED) - { - initializer = default_initializer (); - } + } + + if (current_ts.type == BT_DERIVED && !initializer) + { + initializer = default_initializer (); } /* Add the initializer. Note that it is fine if &initializer is diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 77a80bad099..7e146718672 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2004-05-14 Victor Leikehman + + * gfortran.fortran-torture/execute/def_init_3.f90: New test. + 2004-05-14 Jeff Law * gcc.dg/tree-ssa/20040514-2.c: New test. diff --git a/gcc/testsuite/gfortran.fortran-torture/execute/der_init_3.f90 b/gcc/testsuite/gfortran.fortran-torture/execute/der_init_3.f90 new file mode 100644 index 00000000000..16f203a3059 --- /dev/null +++ b/gcc/testsuite/gfortran.fortran-torture/execute/der_init_3.f90 @@ -0,0 +1,12 @@ +! PR15365 +! Default initializers were being missed +program main + type xyz + integer :: x = 123 + end + + type (xyz) :: a !! ok + type (xyz) b !!! not initialized !!! + if (a%x.ne.123) call abort + if (b%x.ne.123) call abort +end -- 2.30.2