2012-06-13 Tobias Burnus <burnus@net-b.de>
PR fortran/53597
* decl.c (match_attr_spec): Only mark module variables
as SAVE_IMPLICIT for Fortran 2008 and later.
2012-06-13 Tobias Burnus <burnus@net-b.de>
PR fortran/53597
* gfortran.dg/save_4.f90: New.
@@ -3810,8 +3810,9 @@ match_attr_spec (void)
}
}
- /* Module variables implicitly have the SAVE attribute. */
- if (gfc_current_state () == COMP_MODULE && !current_attr.save)
+ /* 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)
current_attr.save = SAVE_IMPLICIT;
colon_seen = 1;
@@ -0,0 +1,13 @@
+! { dg-do compile }
+! { dg-options "-std=f2003" }
+!
+! PR fortran/53597
+!
+MODULE somemodule
+ IMPLICIT NONE
+ TYPE sometype
+ INTEGER :: i
+ DOUBLE PRECISION, POINTER, DIMENSION(:,:) :: coef => NULL()
+ END TYPE sometype
+ TYPE(sometype) :: somevariable ! { dg-error "Fortran 2008: Implied SAVE for module variable 'somevariable' at .1., needed due to the default initialization" }
+END MODULE somemodule