while (ref && ref->next)
ref = ref->next;
- if (selector->ts.type == BT_CLASS && CLASS_DATA (selector)->as
+ if (selector->ts.type == BT_CLASS
+ && CLASS_DATA (selector)
+ && CLASS_DATA (selector)->as
&& CLASS_DATA (selector)->as->type == AS_ASSUMED_RANK)
{
assoc_sym->attr.dimension = 1;
assoc_sym->as = gfc_copy_array_spec (CLASS_DATA (selector)->as);
goto build_class_sym;
}
- else if (selector->ts.type == BT_CLASS && CLASS_DATA (selector)->as
+ else if (selector->ts.type == BT_CLASS
+ && CLASS_DATA (selector)
+ && CLASS_DATA (selector)->as
&& ref && ref->type == REF_ARRAY)
{
/* Ensure that the array reference type is set. We cannot use
{
/* The correct class container has to be available. */
assoc_sym->ts.type = BT_CLASS;
- assoc_sym->ts.u.derived = CLASS_DATA (selector)->ts.u.derived;
+ assoc_sym->ts.u.derived = CLASS_DATA (selector)
+ ? CLASS_DATA (selector)->ts.u.derived : selector->ts.u.derived;
assoc_sym->attr.pointer = 1;
gfc_build_class_symbol (&assoc_sym->ts, &assoc_sym->attr, &assoc_sym->as);
}
{
if (code->expr1->symtree->n.sym->attr.untyped)
code->expr1->symtree->n.sym->ts = code->expr2->ts;
- selector_type = CLASS_DATA (code->expr2)->ts.u.derived;
+ selector_type = CLASS_DATA (code->expr2)
+ ? CLASS_DATA (code->expr2)->ts.u.derived : code->expr2->ts.u.derived;
}
if (code->expr2->rank && CLASS_DATA (code->expr1)->as)
--- /dev/null
+! { dg-do compile }
+! PR fortran/95980 - ICE in get_unique_type_string, at fortran/class.c:485
+
+program p
+ type t
+ end type t
+ class(t) :: x ! { dg-error "must be dummy, allocatable or pointer" }
+ select type (y => x)
+ end select
+end