+2018-12-22 Steven G . Kargl <kargl@gcc.gnu.org>
+
+ PR fortran/85798
+ * decl.c (gfc_match_data): If a component of a derived type entity
+ appears in data statement, check that does not have the allocatable
+ attribute.
+
2018-12-22 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/88169
gfc_match_data (void)
{
gfc_data *new_data;
+ gfc_expr *e;
match m;
/* Before parsing the rest of a DATA statement, check F2008:c1206. */
goto cleanup;
}
+ /* Check for an entity with an allocatable component, which is not
+ allowed. */
+ e = new_data->var->expr;
+ if (e)
+ {
+ bool invalid;
+
+ invalid = false;
+ for (gfc_ref *ref = e->ref; ref; ref = ref->next)
+ if ((ref->type == REF_COMPONENT
+ && ref->u.c.component->attr.allocatable)
+ || (ref->type == REF_ARRAY
+ && e->symtree->n.sym->attr.pointer != 1
+ && ref->u.ar.as && ref->u.ar.as->type == AS_DEFERRED))
+ invalid = true;
+
+ if (invalid)
+ {
+ gfc_error ("Allocatable component or deferred-shaped array "
+ "near %C in DATA statement");
+ goto cleanup;
+ }
+ }
+
m = top_val_list (new_data);
if (m != MATCH_YES)
goto cleanup;
--- /dev/null
+! { dg-do compile }
+program p
+ type t
+ integer, allocatable :: a(:)
+ end type
+ type u
+ real x
+ type(t) y
+ end type
+ type(t) :: z
+ type(u) :: q
+ data z%a(1) / 789 / ! { dg-error "Allocatable component" }
+ data q%y%a(1) / 789 / ! { dg-error "Allocatable component" }
+end