diff mbox

[Fortran,F03] PR 58916: Allocation of scalar with array source not rejected

Message ID CAKwh3qhFOh=8VjNdFerzDo9OQL4-0T079PgRZ-eqhuDR8-BDZA@mail.gmail.com
State New
Headers show

Commit Message

Janus Weil Dec. 11, 2013, 1:02 p.m. UTC
Hi all,

attached is a small patch which fixes accepts-invalid and
ICE-on-invalid problems on allocation with source. Regtested on
x86_64-unknown-linux-gnu. Ok for trunk?

Cheers,
Janus


2013-12-11  Janus Weil  <janus@gcc.gnu.org>

    PR fortran/58916
    * resolve.c (conformable_arrays): Treat scalar 'e2'.
    (resolve_allocate_expr): Check rank also for unlimited-polymorphic
    variables.


2013-12-11  Janus Weil  <janus@gcc.gnu.org>

    PR fortran/58916
    * gfortran.dg/allocate_with_source_4.f90: New.

Comments

Paul Richard Thomas Dec. 11, 2013, 1:35 p.m. UTC | #1
Dear Janus,

It looks good to me - OK for trunk.

Thanks for the patch.

Paul

On 11 December 2013 14:02, Janus Weil <janus@gcc.gnu.org> wrote:
> Hi all,
>
> attached is a small patch which fixes accepts-invalid and
> ICE-on-invalid problems on allocation with source. Regtested on
> x86_64-unknown-linux-gnu. Ok for trunk?
>
> Cheers,
> Janus
>
>
> 2013-12-11  Janus Weil  <janus@gcc.gnu.org>
>
>     PR fortran/58916
>     * resolve.c (conformable_arrays): Treat scalar 'e2'.
>     (resolve_allocate_expr): Check rank also for unlimited-polymorphic
>     variables.
>
>
> 2013-12-11  Janus Weil  <janus@gcc.gnu.org>
>
>     PR fortran/58916
>     * gfortran.dg/allocate_with_source_4.f90: New.
Janus Weil Dec. 11, 2013, 2:04 p.m. UTC | #2
> It looks good to me - OK for trunk.

Thanks, Paul. Committed as r205894.

Cheers,
Janus



> On 11 December 2013 14:02, Janus Weil <janus@gcc.gnu.org> wrote:
>> Hi all,
>>
>> attached is a small patch which fixes accepts-invalid and
>> ICE-on-invalid problems on allocation with source. Regtested on
>> x86_64-unknown-linux-gnu. Ok for trunk?
>>
>> Cheers,
>> Janus
>>
>>
>> 2013-12-11  Janus Weil  <janus@gcc.gnu.org>
>>
>>     PR fortran/58916
>>     * resolve.c (conformable_arrays): Treat scalar 'e2'.
>>     (resolve_allocate_expr): Check rank also for unlimited-polymorphic
>>     variables.
>>
>>
>> 2013-12-11  Janus Weil  <janus@gcc.gnu.org>
>>
>>     PR fortran/58916
>>     * gfortran.dg/allocate_with_source_4.f90: New.
>
>
>
> --
> The knack of flying is learning how to throw yourself at the ground and miss.
>        --Hitchhikers Guide to the Galaxy
diff mbox

Patch

Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c	(revision 205872)
+++ gcc/fortran/resolve.c	(working copy)
@@ -6597,7 +6597,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",
@@ -6794,8 +6795,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.  */