aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/fortran/expr.cc4
-rw-r--r--gcc/testsuite/gfortran.dg/pr108434.f9011
2 files changed, 13 insertions, 2 deletions
diff --git a/gcc/fortran/expr.cc b/gcc/fortran/expr.cc
index 5ec369c..3036b1b 100644
--- a/gcc/fortran/expr.cc
+++ b/gcc/fortran/expr.cc
@@ -4996,14 +4996,14 @@ get_union_initializer (gfc_symbol *union_type, gfc_component **map_p)
static bool
class_allocatable (gfc_component *comp)
{
- return comp->ts.type == BT_CLASS && CLASS_DATA (comp)
+ return comp->ts.type == BT_CLASS && comp->attr.class_ok && CLASS_DATA (comp)
&& CLASS_DATA (comp)->attr.allocatable;
}
static bool
class_pointer (gfc_component *comp)
{
- return comp->ts.type == BT_CLASS && CLASS_DATA (comp)
+ return comp->ts.type == BT_CLASS && comp->attr.class_ok && CLASS_DATA (comp)
&& CLASS_DATA (comp)->attr.pointer;
}
diff --git a/gcc/testsuite/gfortran.dg/pr108434.f90 b/gcc/testsuite/gfortran.dg/pr108434.f90
new file mode 100644
index 0000000..e1768a5
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr108434.f90
@@ -0,0 +1,11 @@
+! { dg-do compile }
+! PR fortran/108434 - ICE in class_allocatable
+! Contributed by G.Steinmetz
+
+program p
+ type t
+ class(c), pointer :: a(2) ! { dg-error "must have a deferred shape" }
+ end type t
+ class(t), allocatable :: x
+ class(t), pointer :: y
+end