This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch, fortran] PR32633 - bogus error with implicit SAVE


Attached patch fixes a somewhat embarassing regression concerning explicit and 
implicite SAVEs. The fix is generally the same as shown in the PR, but 
arranged in a slightly different way. Changes to module.c and 
dump-parse-tree.c are not strictly necessary, but make the transition from a 
1-bit attribute to an enum more complete.


:ADDPATCH fortran:

gcc/fortran:
2007-07-05  Daniel Franke  <franke.daniel@gmail.com>

	PR fortran/32633
	* symbol.c (save_status): New.
	* gfortran.h (save_status): Added external declaration.
	(check_conflict): Check for conflicting explicite SAVE statements only.
	(gen_special_c_interop_ptr): Use SAVE_EXPLICIT constant.
	* module.c (ab_attribute, attr_bits): Removed enumerator value for save
	attribute.
	(mio_symbol_attribute): Import/export the full SAVE status, removed usage 
	of AB_SAVE.
	* dump-parse-tree.c (gfc_show_attr): Dump full SAVE status.
	* decl.c (add_init_expr_to_sym): Set SAVE_IMPLICIT only if not already
	explicit.

gcc/testsuite:
2007-07-05  Daniel Franke  <franke.daniel@gmail.com>

	PR fortran/32633
	* gfortran.dg/module_md5_1.f90: Updated MD5 sum.

[The new md5sum is not part of the patch as I currently have a tree which 
includes not-yet committed changes which will change it again. I will do the 
appropiate update before committing.]


Regtested on i686-pc-linux-gnu. Ok for trunk?


Regards
	Daniel
Index: fortran/symbol.c
===================================================================
--- fortran/symbol.c	(revision 126369)
+++ fortran/symbol.c	(working copy)
@@ -79,6 +79,12 @@
     minit ("USAGE", IFSRC_USAGE)
 };
 
+const mstring save_status[] =
+{
+    minit ("UNKNOWN", SAVE_NONE),
+    minit ("EXPLICIT-SAVE", SAVE_EXPLICIT),
+    minit ("IMPLICIT-SAVE", SAVE_IMPLICIT),
+};
 
 /* This is to make sure the backend generates setup code in the correct
    order.  */
@@ -393,9 +399,34 @@
 	}
     }
 
+  if (attr->save == SAVE_EXPLICIT)
+    {
+      conf (dummy, save);
+      conf (in_common, save);
+      conf (result, save);
+
+      switch (attr->flavor)
+	{
+	  case FL_PROGRAM:
+	  case FL_BLOCK_DATA:
+	  case FL_MODULE:
+	  case FL_LABEL:
+	  case FL_PROCEDURE:
+	  case FL_DERIVED:
+	  case FL_PARAMETER:
+            a1 = gfc_code2string (flavors, attr->flavor);
+            a2 = save;
+	    goto conflict;
+
+	  case FL_VARIABLE:
+	  case FL_NAMELIST:
+	  default:
+	    break;
+	}
+    }
+
   conf (dummy, entry);
   conf (dummy, intrinsic);
-  conf (dummy, save);
   conf (dummy, threadprivate);
   conf (pointer, target);
   conf (pointer, intrinsic);
@@ -407,7 +438,7 @@
   conf (external, dimension);   /* See Fortran 95's R504.  */
 
   conf (external, intrinsic);
-    
+
   if (attr->if_source || attr->contained)
     {
       conf (external, subroutine);
@@ -423,8 +454,6 @@
   conf (in_common, dummy);
   conf (in_common, allocatable);
   conf (in_common, result);
-  conf (in_common, save);
-  conf (result, save);
 
   conf (dummy, result);
 
@@ -536,7 +565,6 @@
     case FL_LABEL:
       conf2 (dimension);
       conf2 (dummy);
-      conf2 (save);
       conf2 (volatile_);
       conf2 (pointer);
       conf2 (protected);
@@ -558,7 +586,6 @@
 
     case FL_PROCEDURE:
       conf2 (intent);
-      conf2 (save);
 
       if (attr->subroutine)
 	{
@@ -586,7 +613,6 @@
 	case PROC_DUMMY:
 	  conf2 (result);
 	  conf2 (in_common);
-	  conf2 (save);
 	  conf2 (threadprivate);
 	  break;
 
@@ -598,7 +624,6 @@
 
     case FL_DERIVED:
       conf2 (dummy);
-      conf2 (save);
       conf2 (pointer);
       conf2 (target);
       conf2 (external);
@@ -630,7 +655,6 @@
       conf2 (target);
       conf2 (dummy);
       conf2 (in_common);
-      conf2 (save);
       conf2 (value);
       conf2 (volatile_);
       conf2 (threadprivate);
@@ -3161,7 +3185,7 @@
 
   /* Set up the symbol's important fields.  Save attr required so we can
      initialize the ptr to NULL.  */
-  tmp_sym->attr.save = 1;
+  tmp_sym->attr.save = SAVE_EXPLICIT;
   tmp_sym->ts.is_c_interop = 1;
   tmp_sym->attr.is_c_interop = 1;
   tmp_sym->ts.is_iso_c = 1;
Index: fortran/module.c
===================================================================
--- fortran/module.c	(revision 126369)
+++ fortran/module.c	(working copy)
@@ -1512,7 +1512,7 @@
 
 typedef enum
 { AB_ALLOCATABLE, AB_DIMENSION, AB_EXTERNAL, AB_INTRINSIC, AB_OPTIONAL,
-  AB_POINTER, AB_SAVE, AB_TARGET, AB_DUMMY, AB_RESULT, AB_DATA,
+  AB_POINTER, AB_TARGET, AB_DUMMY, AB_RESULT, AB_DATA,
   AB_IN_NAMELIST, AB_IN_COMMON, AB_FUNCTION, AB_SUBROUTINE, AB_SEQUENCE,
   AB_ELEMENTAL, AB_PURE, AB_RECURSIVE, AB_GENERIC, AB_ALWAYS_EXPLICIT,
   AB_CRAY_POINTER, AB_CRAY_POINTEE, AB_THREADPRIVATE, AB_ALLOC_COMP,
@@ -1529,7 +1529,6 @@
     minit ("INTRINSIC", AB_INTRINSIC),
     minit ("OPTIONAL", AB_OPTIONAL),
     minit ("POINTER", AB_POINTER),
-    minit ("SAVE", AB_SAVE),
     minit ("VOLATILE", AB_VOLATILE),
     minit ("TARGET", AB_TARGET),
     minit ("THREADPRIVATE", AB_THREADPRIVATE),
@@ -1567,6 +1566,7 @@
 DECL_MIO_NAME (gfc_access)
 DECL_MIO_NAME (gfc_intrinsic_op)
 DECL_MIO_NAME (ifsrc)
+DECL_MIO_NAME (save_state)
 DECL_MIO_NAME (procedure_type)
 DECL_MIO_NAME (ref_type)
 DECL_MIO_NAME (sym_flavor)
@@ -1590,6 +1590,7 @@
   attr->intent = MIO_NAME (sym_intent) (attr->intent, intents);
   attr->proc = MIO_NAME (procedure_type) (attr->proc, procedures);
   attr->if_source = MIO_NAME (ifsrc) (attr->if_source, ifsrc_types);
+  attr->save = MIO_NAME (save_state) (attr->save, save_status);
 
   if (iomode == IO_OUTPUT)
     {
@@ -1607,8 +1608,6 @@
 	MIO_NAME (ab_attribute) (AB_POINTER, attr_bits);
       if (attr->protected)
 	MIO_NAME (ab_attribute) (AB_PROTECTED, attr_bits);
-      if (attr->save)
-	MIO_NAME (ab_attribute) (AB_SAVE, attr_bits);
       if (attr->value)
 	MIO_NAME (ab_attribute) (AB_VALUE, attr_bits);
       if (attr->volatile_)
@@ -1696,9 +1695,6 @@
 	    case AB_PROTECTED:
 	      attr->protected = 1;
 	      break;
-	    case AB_SAVE:
-	      attr->save = 1;
-	      break;
 	    case AB_VALUE:
 	      attr->value = 1;
 	      break;
Index: fortran/dump-parse-tree.c
===================================================================
--- fortran/dump-parse-tree.c	(revision 126369)
+++ fortran/dump-parse-tree.c	(working copy)
@@ -542,10 +548,11 @@
 gfc_show_attr (symbol_attribute *attr)
 {
 
-  gfc_status ("(%s %s %s %s", gfc_code2string (flavors, attr->flavor),
+  gfc_status ("(%s %s %s %s %s", gfc_code2string (flavors, attr->flavor),
 	      gfc_intent_string (attr->intent),
 	      gfc_code2string (access_types, attr->access),
-	      gfc_code2string (procedures, attr->proc));
+	      gfc_code2string (procedures, attr->proc),
+	      gfc_code2string (save_status, attr->save));
 
   if (attr->allocatable)
     gfc_status (" ALLOCATABLE");
@@ -561,8 +568,6 @@
     gfc_status (" POINTER");
   if (attr->protected)
     gfc_status (" PROTECTED");
-  if (attr->save)
-    gfc_status (" SAVE");
   if (attr->value)
     gfc_status (" VALUE");
   if (attr->volatile_)
Index: fortran/gfortran.h
===================================================================
--- fortran/gfortran.h	(revision 126369)
+++ fortran/gfortran.h	(working copy)
@@ -311,6 +315,7 @@
 extern const mstring intents[];
 extern const mstring access_types[];
 extern const mstring ifsrc_types[];
+extern const mstring save_status[];
 
 /* Enumeration of all the generic intrinsic functions.  Used by the
    backend for identification of a function.  */
Index: fortran/decl.c
===================================================================
--- fortran/decl.c	(revision 126369)
+++ fortran/decl.c	(working copy)
@@ -1232,7 +1232,8 @@
 	}
 
       sym->value = init;
-      sym->attr.save = SAVE_IMPLICIT;
+      if (sym->attr.save == SAVE_NONE)
+	sym->attr.save = SAVE_IMPLICIT;
       *initp = NULL;
     }
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]