From: Jerry DeLisle Date: Sun, 29 Jan 2023 04:00:34 +0000 (-0800) Subject: ICE in gfc_free_namespace. ice-on-invalid. X-Git-Tag: releases/gcc-11.5.0~648 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=238bce471c4391c47ffd4cd3f261f40006993f0e;p=thirdparty%2Fgcc.git ICE in gfc_free_namespace. ice-on-invalid. PR fortran/103506 gcc/fortran/ChangeLog: * parse.c (parse_module): Remove use of a bool error value that prevented proper setting of the namespace pointer. gcc/testsuite/ChangeLog: * gfortran.dg/pr103506_1.f90: New test. (cherry picked from commit 8011fbba7baa46947341ca8069b5a327163a68d5) --- diff --git a/gcc/fortran/parse.c b/gcc/fortran/parse.c index 23602446b61f..6893557733bd 100644 --- a/gcc/fortran/parse.c +++ b/gcc/fortran/parse.c @@ -6160,7 +6160,6 @@ parse_module (void) { gfc_statement st; gfc_gsymbol *s; - bool error; s = gfc_get_gsymbol (gfc_new_block->name, false); if (s->defined || (s->type != GSYM_UNKNOWN && s->type != GSYM_MODULE)) @@ -6183,7 +6182,6 @@ parse_module (void) st = parse_spec (ST_NONE); - error = false; loop: switch (st) { @@ -6202,16 +6200,11 @@ loop: default: gfc_error ("Unexpected %s statement in MODULE at %C", gfc_ascii_statement (st)); - - error = true; reject_statement (); st = next_statement (); goto loop; } - - /* Make sure not to free the namespace twice on error. */ - if (!error) - s->ns = gfc_current_ns; + s->ns = gfc_current_ns; } diff --git a/gcc/testsuite/gfortran.dg/pr103506_1.f90 b/gcc/testsuite/gfortran.dg/pr103506_1.f90 new file mode 100644 index 000000000000..3f57809e0999 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr103506_1.f90 @@ -0,0 +1,9 @@ +! { dg-do compile } +! PR103506 ICE in gfc_free_namespace. ice-on-invalid +! Test case from the PR. +module m ! { dg-error "is already being used as a MODULE" } +stop ! { dg-error "Unexpected STOP statement in MODULE" } +end +program p +call m ! { dg-error "is already being used as a MODULE" } +end