[Bug fortran/122046] [14/15/16 Regression] ICE in is_illegal_recursion when a TBP is used to specify the bounds of a dummy argument
cvs-commit at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Mar 19 14:42:00 GMT 2026
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122046
--- Comment #11 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-14 branch has been updated by Paul Thomas <pault@gcc.gnu.org>:
https://gcc.gnu.org/g:7f4342c87cb126fce3f15253f2191b3b9b7c9b49
commit r14-12458-g7f4342c87cb126fce3f15253f2191b3b9b7c9b49
Author: Mikael Morin <morin-mikael@orange.fr>
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)
More information about the Gcc-bugs
mailing list