[Bug fortran/58916] Allocation of scalar with array source not rejected
janus at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Dec 9 11:30:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58916
janus at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |janus at gcc dot gnu.org
--- Comment #3 from janus at gcc dot gnu.org ---
This updated patch rejects both test cases (but is not regtested yet):
Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c (revision 205785)
+++ gcc/fortran/resolve.c (working copy)
@@ -6594,7 +6594,8 @@ conformable_arrays (gfc_expr *e1, gfc_expr *e2)
for (tail = e2->ref; tail && tail->next; tail = tail->next);
/* First compare rank. */
- if (tail && e1->rank != tail->u.ar.as->rank)
+ if ((tail && e1->rank != tail->u.ar.as->rank)
+ || (!tail && e1->rank != e2->rank))
{
gfc_error ("Source-expr at %L must be scalar or have the "
"same rank as the allocate-object at %L",
@@ -6791,8 +6792,7 @@ resolve_allocate_expr (gfc_expr *e, gfc_code *code
}
/* Check F03:C632 and restriction following Note 6.18. */
- if (code->expr3->rank > 0 && !unlimited
- && !conformable_arrays (code->expr3, e))
+ if (code->expr3->rank > 0 && !conformable_arrays (code->expr3, e))
goto failure;
/* Check F03:C633. */
More information about the Gcc-bugs
mailing list