if (var->n.sym->attr.flavor != FL_PROCEDURE
&& ((var->n.sym->as != NULL && var->n.sym->ts.type != BT_CLASS)
- || (var->n.sym->ts.type == BT_CLASS && CLASS_DATA (var->n.sym)
+ || (var->n.sym->ts.type == BT_CLASS && var->n.sym->ts.u.derived
+ && CLASS_DATA (var->n.sym)
&& CLASS_DATA (var->n.sym)->as)))
{
e->rank = var->n.sym->ts.type == BT_CLASS
sym = tmp->n.sym;
gfc_add_type (sym, ts, NULL);
- if (selector->ts.type == BT_CLASS && selector->attr.class_ok)
+ if (selector->ts.type == BT_CLASS && selector->attr.class_ok
+ && selector->ts.u.derived && CLASS_DATA (selector))
{
sym->attr.pointer
= CLASS_DATA (selector)->attr.class_pointer;
&& !(gfc_matching_procptr_assignment
&& sym->attr.flavor == FL_PROCEDURE))
|| (sym->ts.type == BT_CLASS && sym->attr.class_ok
+ && sym->ts.u.derived && CLASS_DATA (sym)
&& (CLASS_DATA (sym)->attr.dimension
|| CLASS_DATA (sym)->attr.codimension)))
{
can't be translated that way. */
if (sym->assoc && e->rank == 0 && e->ref && sym->ts.type == BT_CLASS
&& sym->assoc->target && sym->assoc->target->ts.type == BT_CLASS
+ && sym->assoc->target->ts.u.derived
+ && CLASS_DATA (sym->assoc->target)
&& CLASS_DATA (sym->assoc->target)->as)
{
gfc_ref *ref = e->ref;
/* Like above, but for class types, where the checking whether an array
ref is present is more complicated. Furthermore make sure not to add
the full array ref to _vptr or _len refs. */
- if (sym->assoc && sym->ts.type == BT_CLASS
+ if (sym->assoc && sym->ts.type == BT_CLASS && sym->ts.u.derived
+ && CLASS_DATA (sym)
&& CLASS_DATA (sym)->attr.dimension
&& (e->ts.type != BT_DERIVED || !e->ts.u.derived->attr.vtype))
{
/* Check F03:C815. */
if ((c->ts.type == BT_DERIVED || c->ts.type == BT_CLASS)
+ && selector_type
&& !selector_type->attr.unlimited_polymorphic
&& !gfc_type_is_extensible (c->ts.u.derived))
{
}
/* Check F03:C816. */
- if (c->ts.type != BT_UNKNOWN && !selector_type->attr.unlimited_polymorphic
+ if (c->ts.type != BT_UNKNOWN
+ && selector_type && !selector_type->attr.unlimited_polymorphic
&& ((c->ts.type != BT_DERIVED && c->ts.type != BT_CLASS)
|| !gfc_type_is_extension_of (selector_type, c->ts.u.derived)))
{
--- /dev/null
+! { dg-do compile }
+! PR fortran/102332 - ICE in select_type_set_tmp
+! Contributed by G.Steinmetz
+
+program p
+ type t
+ real :: a, b
+ end type
+ class(t), allocatable :: x ! Valid
+ select type (y => x)
+ type is (t)
+ y%a = 0
+ end select
+end
+
+subroutine s0 (x)
+ type t
+ real :: a, b
+ end type
+ class(t) :: x ! Valid
+ select type (y => x)
+ type is (t)
+ y%a = 0
+ end select
+end
+
+subroutine s1
+ type t
+ real :: a, b
+ end type
+ class(t) :: x ! { dg-error "must be dummy, allocatable or pointer" }
+ select type (y => x)
+ type is (t)
+ y%a = 0
+ end select
+end
+
+subroutine s3
+ type t
+ real :: a, b
+ end type
+ class(t) :: x ! { dg-error "must be dummy, allocatable or pointer" }
+ select type (y => x)
+ class is (t)
+ y%a = 0
+ end select
+end
+
+subroutine s2
+ type t
+ real :: a, b
+ end type
+ class(t) :: x ! { dg-error "must be dummy, allocatable or pointer" }
+ select type (y => x)
+ type default ! { dg-error "Expected" }
+ y%a = 0
+ end select
+end
+
+subroutine s4
+ type t
+ real :: a, b
+ end type
+ class(t) :: x ! { dg-error "must be dummy, allocatable or pointer" }
+ select type (y => x)
+ class default
+ y%a = 0
+ end select
+end