This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch/gfortran] fix to pr 15365
- From: Victor Leikehman <lei at haifasphere dot co dot il>
- To: gcc-patches at gcc dot gnu dot org, fortran at gcc dot gnu dot org
- Date: Tue, 11 May 2004 11:09:27 +0300
- Subject: [patch/gfortran] fix to pr 15365
- Organization: IBM Research Lab in Haifa, Israel
- Reply-to: lei at il dot ibm dot com
When a variable of derived type was defined without :: (such as b in the
example below), its initializer was not set to the default initializer.
Fixed as attached. Regtested.
Victor
program main
type xyz
integer :: x = 123
end
type (xyz) :: a !! ok
type (xyz) b !!! not initialized !!!
print*, a%x, b%x
if (a%x.ne.123) call abort
if (b%x.ne.123) call abort
end
Index: decl.c
===================================================================
RCS file: /home/lei/cvsroot/fortran/decl.c,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 decl.c
--- decl.c 4 Feb 2004 11:42:50 -0000 1.1.1.1
+++ decl.c 11 May 2004 07:39:17 -0000
@@ -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
--
Victor Leikehman
IBM Research Labs in Haifa, Israel