https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103508
--- Comment #7 from kargls at comcast dot net ---
This fixes the issue.
iff --git a/gcc/fortran/decl.cc b/gcc/fortran/decl.cc
index 99644939056..102c6a8e8df 100644
--- a/gcc/fortran/decl.cc
+++ b/gcc/fortran/decl.cc
@@ -8986,7 +8986,7 @@ cleanup:
/* If we are missing an END BLOCK, we created a half-ready namespace.
Remove it from the parent namespace's sibling list. */
- while (state == COMP_BLOCK && !got_matching_end)
+ if (state == COMP_BLOCK && !got_matching_end)
{
parent_ns = gfc_current_ns->parent;
Basically, the while() loop not removes not only the current partial
namespace for the inner block-end construct but continues up the list
and removes the outer block-end construct. So, when the parser tries
to complete the outer block-end construct, its namespace has already
been reaped. Changing while() to if() removed only the current partial
namespace.