Patchwork [Fortran] PR53597 re-add SAVE constraint for modules with -std=f2003

login
register
mail settings
Submitter Tobias Burnus
Date June 13, 2012, 7:50 a.m.
Message ID <4FD84658.6040009@net-b.de>
Download mbox | patch
Permalink /patch/164558/
State New
Headers show

Comments

Tobias Burnus - June 13, 2012, 7:50 a.m.
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
Paul Richard Thomas - June 13, 2012, 11:48 a.m.
Dear Tobias,

This one is indeed obvious!  OK for trunk.

Cheers

Paul

On 13 June 2012 09:50, Tobias Burnus <burnus@net-b.de> wrote:
> 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
>

Patch

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.

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