Given the very slow patch review, I intent to commit this patch in a
couple of days as obvious.* Nevertheless, I wouldn't mind a patch review.
The constraint check is actually present in resolve.c, it just doesn't
trigger.
Build and regtested on x86-64-gnu-linux.
OK for the trunk - and for the 4.6/4.7 branch?*
Patches pending review:
- http://gcc.gnu.org/ml/fortran/2012-05/msg00171.html
- http://gcc.gnu.org/ml/fortran/2012-05/msg00173.html
Tobias
2012-06-13 Tobias Burnus <bur...@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 <bur...@net-b.de>
PR fortran/53597
* gfortran.dg/save_4.f90: New.
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index a760331..26b5059 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -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;
--- /dev/null 2012-06-12 08:13:11.079779038 +0200
+++ gcc/gcc/testsuite/gfortran.dg/save_4.f90 2012-06-13 09:16:20.000000000 +0200
@@ -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