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] PR69498 Fix ICE on unexpected submodule


Hello everyone,

this fixes the ICE. The problem was a discrepancy between the name of the submodules symbol and the name of its symtree node.

Nicolas

2017-03-18  Nicolas Koenig  <koenigni@student.ethz.ch>
                PR fortran/69498
* symbol.c (gfc_delete_symtree): If there is a period in the name, ignore
                everything before it.

2017-03-18  Nicolas Koenig  <koenigni@student.ethz.ch>
                PR fortran/69498
                * gfortran.dg/submodule_unexp.f90: New test



Index: symbol.c
===================================================================
--- symbol.c	(Revision 246320)
+++ symbol.c	(Arbeitskopie)
@@ -2782,10 +2782,20 @@ void
 gfc_delete_symtree (gfc_symtree **root, const char *name)
 {
   gfc_symtree st, *st0;
+  const char *p;
 
-  st0 = gfc_find_symtree (*root, name);
+  /* Submodules are marked as mod.submod.  When freeing a submodule
+     symbol, the symtree only has "submod", so adjust that here.  */
 
-  st.name = gfc_get_string ("%s", name);
+  p = strchr(name, '.');
+  if (p)
+    p++;
+  else
+    p = name;
+
+  st0 = gfc_find_symtree (*root, p);
+
+  st.name = gfc_get_string ("%s", p);
   gfc_delete_bbt (root, &st, compare_symtree);
 
   free (st0);
! { dg-do compile }
! PR fortran/69498
! This used to ICE
program p
   type t
   submodule (m) sm ! { dg-error "Unexpected SUBMODULE statement at" }
   end type
end

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