aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/symbol.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/fortran/symbol.cc')
-rw-r--r--gcc/fortran/symbol.cc15
1 files changed, 14 insertions, 1 deletions
diff --git a/gcc/fortran/symbol.cc b/gcc/fortran/symbol.cc
index 81aa81d..8211d92 100644
--- a/gcc/fortran/symbol.cc
+++ b/gcc/fortran/symbol.cc
@@ -5500,7 +5500,16 @@ gfc_namespace *
gfc_get_procedure_ns (gfc_symbol *sym)
{
if (sym->formal_ns
- && sym->formal_ns->proc_name == sym)
+ && sym->formal_ns->proc_name == sym
+ /* For module procedures used in submodules, there are two namespaces.
+ The one generated by the host association of the module is directly
+ accessible through SYM->FORMAL_NS but doesn't have any parent set.
+ The one generated by the parser is only accessible by walking the
+ contained namespace but has its parent set. Prefer the one generated
+ by the parser below. */
+ && !(sym->attr.used_in_submodule
+ && sym->attr.contained
+ && sym->formal_ns->parent == nullptr))
return sym->formal_ns;
/* The above should have worked in most cases. If it hasn't, try some other
@@ -5515,6 +5524,10 @@ gfc_get_procedure_ns (gfc_symbol *sym)
if (ns->proc_name == sym)
return ns;
+ if (sym->formal_ns
+ && sym->formal_ns->proc_name == sym)
+ return sym->formal_ns;
+
if (sym->formal)
for (gfc_formal_arglist *f = sym->formal; f != nullptr; f = f->next)
if (f->sym)