https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122046
--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Mikael Morin <[email protected]>: https://gcc.gnu.org/g:33862166186fcef86e94babded780bb3745f6525 commit r16-4082-g33862166186fcef86e94babded780bb3745f6525 Author: Mikael Morin <[email protected]> Date: Wed Sep 24 16:06:59 2025 +0200 fortran: Favor parser-generated module procedure namespaces [PR122046] In the testcase from the PR, an assertion triggers because the compiler tries to access the parent namespace of a contained procedure. But the namespace is the formal namespace of a module procedure symbol in a submodule, which hasn't its parent set. To add a bit of context, in submodules, module procedures inherited from their parent module have two different namespaces holding their dummy arguments. The first one is generated by the the host association of the module from the .mod file, and is made accessible in the procedure symbol's formal_ns field. Its parent field is not set. The second one is generated by the parser and contains the procedure implementation. It's accessible from the list of contained procedures in the submodule namespace. Its parent field is set. This change modifies gfc_get_procedure_ns to favor the parser-generated namespace in the submodule case where there are two namespaces to choose from. PR fortran/122046 gcc/fortran/ChangeLog: * symbol.cc (gfc_get_procedure_ns): Try to find the namespace among the list of contained namespaces before returning the value from the formal_ns field. gcc/testsuite/ChangeLog: * gfortran.dg/submodule_34.f90: New test.
