aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAndre Vehreschild <vehre@gcc.gnu.org>2025-03-03 14:42:28 +0100
committerAndre Vehreschild <vehre@gcc.gnu.org>2025-03-04 09:38:14 +0100
commit5bd664838398980f1c8af60a946947ff83744fcc (patch)
tree29259ae73c93e28c1fbfa40c56385a8d82a503c2 /gcc
parentef605e106c6075bfe2a5625add7185a9a3f722b1 (diff)
downloadgcc-5bd664838398980f1c8af60a946947ff83744fcc.zip
gcc-5bd664838398980f1c8af60a946947ff83744fcc.tar.gz
gcc-5bd664838398980f1c8af60a946947ff83744fcc.tar.bz2
Fortran: Prevent ICE when getting caf-token from abstract type [PR77872]
PR fortran/77872 gcc/fortran/ChangeLog: * trans-expr.cc (gfc_get_tree_for_caf_expr): Pick up token from decl when it is present there for class types. gcc/testsuite/ChangeLog: * gfortran.dg/coarray/class_1.f90: New test.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/trans-expr.cc5
-rw-r--r--gcc/testsuite/gfortran.dg/coarray/class_1.f9016
2 files changed, 21 insertions, 0 deletions
diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index 7c0b174..0d790b6 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -2394,6 +2394,11 @@ gfc_get_tree_for_caf_expr (gfc_expr *expr)
if (CLASS_DATA (expr->symtree->n.sym)->attr.codimension)
return caf_decl;
}
+ else if (DECL_P (caf_decl) && DECL_LANG_SPECIFIC (caf_decl)
+ && GFC_DECL_TOKEN (caf_decl)
+ && CLASS_DATA (expr->symtree->n.sym)->attr.codimension)
+ return caf_decl;
+
for (ref = expr->ref; ref; ref = ref->next)
{
if (ref->type == REF_COMPONENT
diff --git a/gcc/testsuite/gfortran.dg/coarray/class_1.f90 b/gcc/testsuite/gfortran.dg/coarray/class_1.f90
new file mode 100644
index 0000000..fa70b1d
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/coarray/class_1.f90
@@ -0,0 +1,16 @@
+!{ dg-do compile }
+!
+! Compiling the call x%f() ICEd. Check it's fixed.
+! Contributed by Gerhard Steinmetz <gerhard.steinmetz.fortran@t-online.de>
+
+module pr77872_abs
+ type, abstract :: t
+ contains
+ procedure(s), pass, deferred :: f
+ end type
+contains
+ subroutine s(x)
+ class(t) :: x[*]
+ call x%f()
+ end
+end module pr77872_abs