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

--- Comment #2 from Gilles Gouaillardet <gilles.gouaillardet at gmail dot com> 
---
FWIW, the inline patch below does the trick.
I honestly have no idea whether this is a correct fix or not.


diff --git a/gcc/fortran/trans-decl.cc b/gcc/fortran/trans-decl.cc
index b077cee86a3..fb57c6c6f44 100644
--- a/gcc/fortran/trans-decl.cc
+++ b/gcc/fortran/trans-decl.cc
@@ -2520,6 +2520,8 @@ build_function_decl (gfc_symbol * sym, bool global)
   /* Allow only one nesting level.  Allow public declarations.  */
   gcc_assert (current_function_decl == NULL_TREE
              || DECL_FILE_SCOPE_P (current_function_decl)
+             || (TREE_CODE (DECL_CONTEXT (current_function_decl))
+                 == FUNCTION_DECL)
              || (TREE_CODE (DECL_CONTEXT (current_function_decl))
                  == NAMESPACE_DECL));

Reply via email to