[gcc r15-11458] fortran: [PR125866] Fix ICE: a module procedure with an allocatable, intent(out)
Jerry DeLisle via Gcc-cvs <[email protected]> Wed, 5 Aug 2026 02:52:38 +0000 (GMT)
| Newsgroups | gmane.comp.gcc.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://gcc.gnu.org/g:801e78ed285a3de14b24c03a435d76eb6b393202 commit r15-11458-g801e78ed285a3de14b24c03a435d76eb6b393202 Author: Jerry DeLisle <[email protected]> Date: Tue Jul 28 12:53:30 2026 -0700 fortran: [PR125866] Fix ICE: a module procedure with an allocatable, intent(out) Co-authored by: Steve Kargl <[email protected]> PR fortran/125866 gcc/fortran/ChangeLog: * expr.cc (is_CFI_desc): Add check for proc_name. gcc/testsuite/ChangeLog: * gfortran.dg/pr125866.f90: New test. (cherry picked from commit 2886a168e82e603f8141d5ea633a0eb0a4a58a6e) Diff: --- gcc/fortran/expr.cc | 2 +- gcc/testsuite/gfortran.dg/pr125866.f90 | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/gcc/fortran/expr.cc b/gcc/fortran/expr.cc index 4671c7836099..ccb1a2c89f5a 100644 --- a/gcc/fortran/expr.cc +++ b/gcc/fortran/expr.cc @@ -1154,7 +1154,7 @@ is_CFI_desc (gfc_symbol *sym, gfc_expr *e) && e && e->expr_type == EXPR_VARIABLE) sym = e->symtree->n.sym; - if (sym && sym->attr.dummy + if (sym && sym->attr.dummy && sym->ns && sym->ns->proc_name && sym->ns->proc_name->attr.is_bind_c && (sym->attr.pointer || sym->attr.allocatable diff --git a/gcc/testsuite/gfortran.dg/pr125866.f90 b/gcc/testsuite/gfortran.dg/pr125866.f90 new file mode 100644 index 000000000000..e0bc7b746f69 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr125866.f90 @@ -0,0 +1,28 @@ +! { dg-do compile } +! ICE: a module procedure with an allocatable, intent(out) +! derived-type array dummy. Reduced from the original in the PR + +module m + interface + module subroutine s (a) + integer, allocatable, intent(out) :: a + end subroutine + end interface +end module + +submodule (m) sm1 +contains + module subroutine s (a) + integer, allocatable, intent(out) :: a + allocate (a, source = 7) + end subroutine +end submodule + +submodule (m:sm1) sm2 +contains + subroutine caller + integer, allocatable :: b + call s (b) + if (b /= 7) stop 1 + end subroutine +end submodule