From: Mikael Morin Date: Wed, 28 Mar 2018 20:12:55 +0000 (+0000) Subject: re PR fortran/69497 (ICE in gfc_free_namespace, at fortran/symbol.c:3701) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9b0588e9362bdd86f4cfdbe115e220b38ed23aaa;p=gcc.git re PR fortran/69497 (ICE in gfc_free_namespace, at fortran/symbol.c:3701) PR fortran/69497 * symbol.c (gfc_symbol_done_2): Start freeing namespaces from the root. (gfc_free_namespace): Restore assert (revert r258839). From-SVN: r258935 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 85fcaae0890..9c13ff060c3 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2018-03-28 Mikael Morin + + PR fortran/69497 + * symbol.c (gfc_symbol_done_2): Start freeing namespaces + from the root. + (gfc_free_namespace): Restore assert (revert r258839). + 2018-03-28 Jakub Jelinek * gfortran.h (gfc_dt): Rename default_exp field to dec_ext. diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c index 997d90b00fd..546a4fae0a8 100644 --- a/gcc/fortran/symbol.c +++ b/gcc/fortran/symbol.c @@ -4037,10 +4037,11 @@ gfc_free_namespace (gfc_namespace *ns) return; ns->refs--; - - if (ns->refs != 0) + if (ns->refs > 0) return; + gcc_assert (ns->refs == 0); + gfc_free_statements (ns->code); free_sym_tree (ns->sym_root); @@ -4087,8 +4088,14 @@ gfc_symbol_init_2 (void) void gfc_symbol_done_2 (void) { - gfc_free_namespace (gfc_current_ns); - gfc_current_ns = NULL; + if (gfc_current_ns != NULL) + { + /* free everything from the root. */ + while (gfc_current_ns->parent != NULL) + gfc_current_ns = gfc_current_ns->parent; + gfc_free_namespace (gfc_current_ns); + gfc_current_ns = NULL; + } gfc_free_dt_list (); enforce_single_undo_checkpoint ();