https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84386
--- Comment #6 from Harald Anlauf <anlauf at gcc dot gnu.org> ---
I had the stupid idea of creating the implicitly defined variables in the
parent namespaces using:
diff --git a/gcc/fortran/symbol.cc b/gcc/fortran/symbol.cc
index 72ffa191954..fc30f0f4ae4 100644
--- a/gcc/fortran/symbol.cc
+++ b/gcc/fortran/symbol.cc
@@ -3663,6 +3663,9 @@ gfc_get_sym_tree (const char *name, gfc_namespace *ns,
gfc_symtree **result,
if (st == NULL)
{
+ /* If we are inside a BLOCK, create symbol in parent namespace. */
+ ns = gfc_find_proc_namespace (ns);
+
/* If not there, create a new symbol. */
p = gfc_new_symbol (name, ns, where);
which "fixes" subroutines block1 and block3, but fails badly on block2
and even more on the testsuite.
So while the above is not the right patch, the tree dump appears reasonable.