===================================================================
@@ -72,14 +72,18 @@ along with GCC; see the file COPYING3. If not see
static void
insert_component_ref (gfc_typespec *ts, gfc_ref **ref, const char * const name)
{
- gfc_symbol *type_sym;
gfc_ref *new_ref;
+ int wcnt, ecnt;
gcc_assert (ts->type == BT_DERIVED || ts->type == BT_CLASS);
- type_sym = ts->u.derived;
- gfc_find_component (type_sym, name, true, true, &new_ref);
+ gfc_find_component (ts->u.derived, name, true, true, &new_ref);
+
+ gfc_get_errors (&wcnt, &ecnt);
+ if (ecnt > 0 && !new_ref)
+ return;
gcc_assert (new_ref->u.c.component);
+
while (new_ref->next)
new_ref = new_ref->next;
new_ref->next = *ref;
===================================================================
@@ -4563,7 +4563,7 @@ parse_associate (void)
else
rank = a->target->rank;
/* When the rank is greater than zero then sym will be an array. */
- if (sym->ts.type == BT_CLASS)
+ if (sym->ts.type == BT_CLASS && CLASS_DATA (sym))
{
if ((!CLASS_DATA (sym)->as && rank != 0)
|| (CLASS_DATA (sym)->as
===================================================================
@@ -8715,7 +8715,8 @@ resolve_assoc_var (gfc_symbol* sym, bool resolve_targe
{
/* target's rank is 0, but the type of the sym is still array valued,
which has to be corrected. */
- if (sym->ts.type == BT_CLASS && CLASS_DATA (sym)->as)
+ if (sym->ts.type == BT_CLASS
+ && CLASS_DATA (sym) && CLASS_DATA (sym)->as)
{
gfc_array_spec *as;
symbol_attribute attr;
===================================================================
@@ -0,0 +1,9 @@
+! { dg-do compile }
+! { dg-options "-fcoarray=single" }
+program p
+ type t
+ end type
+ class(t) :: x[*] ! { dg-error "must be dummy, allocatable or pointer" }
+ associate (y => x)
+ end associate
+end
===================================================================
@@ -0,0 +1,8 @@
+! { dg-do compile }
+program p
+ type t
+ end type
+ class(t) :: x ! { dg-error "must be dummy, allocatable or pointer" }
+ associate (y => x)
+ end associate
+end