re PR fortran/56674 (ICE in check_sym_interfaces)
authorMikael Morin <mikael@gcc.gnu.org>
Fri, 10 Apr 2015 11:29:53 +0000 (11:29 +0000)
committerMikael Morin <mikael@gcc.gnu.org>
Fri, 10 Apr 2015 11:29:53 +0000 (11:29 +0000)
PR fortran/56674
PR fortran/58813
PR fortran/59016
PR fortran/59024
fortran/
* symbol.c (save_symbol_data, gfc_save_symbol_data): Rename the
former to the latter and make it non-static.  Update callers.
* gfortran.h (gfc_save_symbol_data): New prototype.
* decl.c (gfc_match_decl_type_spec): Call 'gfc_save_symbol_data'
before modifying symbols 'sym' and 'dt_sym'.
testsuite/
* gfortran.dg/used_types_27.f90: New.

From-SVN: r221972

gcc/fortran/ChangeLog
gcc/fortran/decl.c
gcc/fortran/gfortran.h
gcc/fortran/symbol.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/used_types_27.f90 [new file with mode: 0644]

index 78305a0f7bd0d5ff20f2ce6347f31ebaf3aa0f7c..d3fa35985ff3b4b53a2a5e490abcef352d6ece8d 100644 (file)
@@ -1,3 +1,15 @@
+2015-04-10  Mikael Morin  <mikael@gcc.gnu.org>
+
+       PR fortran/56674
+       PR fortran/58813
+       PR fortran/59016
+       PR fortran/59024
+       * symbol.c (save_symbol_data, gfc_save_symbol_data): Rename the
+       former to the latter and make it non-static.  Update callers.
+       * gfortran.h (gfc_save_symbol_data): New prototype.
+       * decl.c (gfc_match_decl_type_spec): Call 'gfc_save_symbol_data'
+       before modifying symbols 'sym' and 'dt_sym'.
+
 2013-04-09  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/56852
index 40d851c5f5c7c5102c914f130bf2dd1b88d36889..037a8cc47c3aabe5633888aebbba4691151c5e71 100644 (file)
@@ -2876,6 +2876,7 @@ gfc_match_decl_type_spec (gfc_typespec *ts, int implicit_flag)
       return MATCH_ERROR;
     }
 
+  gfc_save_symbol_data (sym);
   gfc_set_sym_referenced (sym);
   if (!sym->attr.generic
       && !gfc_add_generic (&sym->attr, sym->name, NULL))
@@ -2900,6 +2901,8 @@ gfc_match_decl_type_spec (gfc_typespec *ts, int implicit_flag)
       sym->generic = intr;
       sym->attr.if_source = IFSRC_DECL;
     }
+  else
+    gfc_save_symbol_data (dt_sym);
 
   gfc_set_sym_referenced (dt_sym);
 
index 24d56c08b7ab07f4ca4482f45684fecf4497bc56..9d09de6c53b14634d1e64a5fba940d0544bb12d4 100644 (file)
@@ -2819,6 +2819,7 @@ bool verify_bind_c_derived_type (gfc_symbol *);
 bool verify_com_block_vars_c_interop (gfc_common_head *);
 gfc_symtree *generate_isocbinding_symbol (const char *, iso_c_binding_symbol,
                                          const char *, gfc_symtree *, bool);
+void gfc_save_symbol_data (gfc_symbol *);
 int gfc_get_sym_tree (const char *, gfc_namespace *, gfc_symtree **, bool);
 int gfc_get_ha_symbol (const char *, gfc_symbol **);
 int gfc_get_ha_sym_tree (const char *, gfc_symtree **);
index 32eea2141be71bbeaa4921b58a03a859ecd47a61..44392e8d19104d14a36fb047bba7a7f92a6b9809 100644 (file)
@@ -2758,8 +2758,8 @@ single_undo_checkpoint_p (void)
 
 /* Save symbol with the information necessary to back it out.  */
 
-static void
-save_symbol_data (gfc_symbol *sym)
+void
+gfc_save_symbol_data (gfc_symbol *sym)
 {
   gfc_symbol *s;
   unsigned i;
@@ -2860,7 +2860,7 @@ gfc_get_sym_tree (const char *name, gfc_namespace *ns, gfc_symtree **result,
       p->mark = 1;
 
       /* Copy in case this symbol is changed.  */
-      save_symbol_data (p);
+      gfc_save_symbol_data (p);
     }
 
   *result = st;
@@ -2899,7 +2899,7 @@ gfc_get_ha_sym_tree (const char *name, gfc_symtree **result)
 
   if (st != NULL)
     {
-      save_symbol_data (st->n.sym);
+      gfc_save_symbol_data (st->n.sym);
       *result = st;
       return i;
     }
index 6a27daa78e68317c30986b94c3222beef1707ec3..337ef1aa8c224ea9a84fda689765fe02312b4f6d 100644 (file)
@@ -1,3 +1,11 @@
+2015-04-10  Mikael Morin  <mikael@gcc.gnu.org>
+
+       PR fortran/56674
+       PR fortran/58813
+       PR fortran/59016
+       PR fortran/59024
+       * gfortran.dg/used_types_27.f90: New.
+
 2015-04-09  Kirill Yukhin  <kirill.yukhin@intel.com>
 
        PR target/65671
diff --git a/gcc/testsuite/gfortran.dg/used_types_27.f90 b/gcc/testsuite/gfortran.dg/used_types_27.f90
new file mode 100644 (file)
index 0000000..4797f85
--- /dev/null
@@ -0,0 +1,18 @@
+! { dg-do compile }
+!
+! PR fortran/56674
+! PR fortran/58813
+! PR fortran/59016
+! PR fortran/59024
+! The generic name 'atomic_kind_types' was keeping pointers to freed
+! symbols, leading to random error-recovery ICEs.
+!
+! Original test case from Joost VandeVondele <Joost.VandeVondele@mat.ethz.ch>.
+
+MODULE atomic_kind_types
+  PUBLIC :: atomic_kind_type
+CONTAINS
+  INTEGER FUNCTION is_hydrogen(atomic_kind)
+    TYPE(atomic_kind_type), pointer :: atomic_kind ! { dg-error "used before it is defined" }
+  END FUNCTION
+END MODULE