This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/55207] Automatic deallocation of variables declared in the main program
- From: "janus at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 04 Nov 2012 22:48:37 +0000
- Subject: [Bug fortran/55207] Automatic deallocation of variables declared in the main program
- Auto-submitted: auto-generated
- References: <bug-55207-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55207
--- Comment #3 from janus at gcc dot gnu.org 2012-11-04 22:48:37 UTC ---
The following patch applies the implicit SAVE attribute to variables declared
in the main program:
Index: gcc/fortran/decl.c
===================================================================
--- gcc/fortran/decl.c (revision 193137)
+++ gcc/fortran/decl.c (working copy)
@@ -3812,9 +3812,11 @@ match_attr_spec (void)
}
}
- /* Since Fortran 2008 module variables implicitly have the SAVE attribute.
*/
- if (gfc_current_state () == COMP_MODULE && !current_attr.save
- && (gfc_option.allow_std & GFC_STD_F2008) != 0)
+ /* Since Fortran 2008, variables declared in a MODULE or PROGRAM
+ implicitly have the SAVE attribute. */
+ if ((gfc_current_state () == COMP_MODULE
+ || gfc_current_state () == COMP_PROGRAM)
+ && !current_attr.save && (gfc_option.allow_std & GFC_STD_F2008) != 0)
current_attr.save = SAVE_IMPLICIT;
colon_seen = 1;
This also removes the automatic allocation of both variables in the test case
in comment 0. Therefore it has the same testsuite failures as the patch in
comment 1 (possibly more?).