https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102366

--- Comment #8 from anlauf at gcc dot gnu.org ---
Potential fix for comment#0:

diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index bed61e2325d..54309646aad 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -709,6 +709,11 @@ gfc_finish_var_decl (tree decl, gfc_symbol * sym)
        }
     }

+  /* Implicit SAVE (F2018, 8.5.16 SAVE attribute, clause 4).  */
+  if (sym->ns->proc_name && sym->ns->proc_name->attr.is_main_program
+      && sym->attr.save == SAVE_NONE)
+    sym->attr.save = SAVE_IMPLICIT;
+
   /* Derived types are a bit peculiar because of the possibility of
      a default initializer; this must be applied each time the variable
      comes into scope it therefore need not be static.  These variables

Works for me, but not regtested yet.

Does that help?

Of course that handles only part of that clause, and we need extended
testcases.

Reply via email to