This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Patch, fortran] PR69498 Fix ICE on unexpected submodule
- From: Nicolas Koenig <koenigni at student dot ethz dot ch>
- To: <fortran at gcc dot gnu dot org>
- Cc: <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 25 Mar 2017 22:34:54 +0100
- Subject: [Patch, fortran] PR69498 Fix ICE on unexpected submodule
- Authentication-results: sourceware.org; auth=none
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