diff mbox

[fortran] PR69498 Fix ICE on unexpected submodule

Message ID 94229700-2fe2-759f-973c-cc163d9297f5@student.ethz.ch
State New
Headers show

Commit Message

Nicolas Koenig March 25, 2017, 9:34 p.m. UTC
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
diff mbox

Patch

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);