Pushed to 15
commit 05874561c86c206fd05a0df95de675919413bfe2 (HEAD -> gcc15, origin/releases/
gcc-15)
Author: Mikael Morin <[email protected]>
Date: Wed Sep 24 16:06:59 2025 +0200
fortran: Favor parser-generated module procedure namespaces [PR122046]
On 3/17/26 8:09 PM, Jerry D wrote:
Mikael's patch backported and regression tested on 15.2.1.
I plan to commit this in a day or so to help keep things moving along.
Thanks for work Mikael!
Regards,
Jerry
commit fb5b25c7103d5f373733a9b75a13600665b33954 (HEAD -> gcc15)
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.
(cherry picked from commit 33862166186fcef86e94babded780bb3745f6525)