aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorPaul Thomas <pault@gcc.gnu.org>2025-01-23 08:27:04 +0000
committerPaul Thomas <pault@gcc.gnu.org>2025-01-23 08:27:17 +0000
commitb3f51ea894947e495baffc67407647a3b25acdd5 (patch)
treed4483d00b02461878a3a1a268b8b4ce98c461d97 /gcc/fortran
parent7fffff1deb47a70ff804f0b2cce7be7e5fe8ba13 (diff)
downloadgcc-b3f51ea894947e495baffc67407647a3b25acdd5.zip
gcc-b3f51ea894947e495baffc67407647a3b25acdd5.tar.gz
gcc-b3f51ea894947e495baffc67407647a3b25acdd5.tar.bz2
Fortran: Regression- fix ICE at fortran/trans-decl.c:1575 [PR96087]
2025-01-23 Paul Thomas <pault@gcc.gnu.org> gcc/fortran PR fortran/96087 * trans-decl.cc (gfc_get_symbol_decl): If a dummy is missing a backend decl, it is likely that it has come from a module proc interface. Look for the formal symbol by name in the containing proc and use its backend decl. * trans-expr.cc (gfc_apply_interface_mapping_to_expr): For the same reason, match the name, rather than the symbol address to perform the mapping. gcc/testsuite/ PR fortran/96087 * gfortran.dg/pr96087.f90: New test.
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/trans-decl.cc15
-rw-r--r--gcc/fortran/trans-expr.cc2
2 files changed, 16 insertions, 1 deletions
diff --git a/gcc/fortran/trans-decl.cc b/gcc/fortran/trans-decl.cc
index 4ae22a5..97bb0a4 100644
--- a/gcc/fortran/trans-decl.cc
+++ b/gcc/fortran/trans-decl.cc
@@ -1722,6 +1722,21 @@ gfc_get_symbol_decl (gfc_symbol * sym)
sym->backend_decl = DECL_CHAIN (sym->backend_decl);
}
+ /* Automatic array indices in module procedures need the backend_decl
+ to be extracted from the procedure formal arglist. */
+ if (sym->attr.dummy && !sym->backend_decl)
+ {
+ gfc_formal_arglist *f;
+ for (f = sym->ns->proc_name->formal; f; f = f->next)
+ {
+ gfc_symbol *fsym = f->sym;
+ if (strcmp (sym->name, fsym->name))
+ continue;
+ sym->backend_decl = fsym->backend_decl;
+ break;
+ }
+ }
+
/* Dummy variables should already have been created. */
gcc_assert (sym->backend_decl);
diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index dcf42d5..78caf1f 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -5099,7 +5099,7 @@ gfc_apply_interface_mapping_to_expr (gfc_interface_mapping * mapping,
/* TODO Find out why the condition on expr->symtree had to be moved into
the loop rather than being outside it, as originally. */
for (sym = mapping->syms; sym; sym = sym->next)
- if (expr->symtree && sym->old == expr->symtree->n.sym)
+ if (expr->symtree && !strcmp (sym->old->name, expr->symtree->n.sym->name))
{
if (sym->new_sym->n.sym->backend_decl)
expr->symtree = sym->new_sym;