From 15f12d9677a4f8284578d03003fca4a6b78cc6d4 Mon Sep 17 00:00:00 2001 From: Nicolas Koenig Date: Tue, 4 Apr 2017 15:41:41 +0200 Subject: [PATCH] [multiple changes] 2017-03-18 Nicolas Koenig 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 PR fortran/69498 * gfortran.dg/submodule_unexp.f90: New test. From-SVN: r246679 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/symbol.c | 14 ++++++++++++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/submodule_unexp.f90 | 8 ++++++++ 4 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/submodule_unexp.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 7528f37a020..e1057d72eb8 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2017-03-18 Nicolas Koenig + + PR fortran/69498 + * symbol.c (gfc_delete_symtree): If there is a period in the name, ignore + everything before it. + 2017-03-28 Janus Weil PR fortran/78661 diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c index 6226bca7bec..ec43e635bf3 100644 --- a/gcc/fortran/symbol.c +++ b/gcc/fortran/symbol.c @@ -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 = strrchr(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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e14af29e2b9..2d5f91aa81e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-04-04 Nicolas Koenig + + PR fortran/69498 + * gfortran.dg/submodule_unexp.f90: New test. + 2017-04-04 Jakub Jelinek PR target/80286 diff --git a/gcc/testsuite/gfortran.dg/submodule_unexp.f90 b/gcc/testsuite/gfortran.dg/submodule_unexp.f90 new file mode 100644 index 00000000000..43a055349d8 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/submodule_unexp.f90 @@ -0,0 +1,8 @@ +! { 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