This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch, fortran, committed] Fix PR 71795


Hello world,

I have committed the attached patch as obvious and simple
after regression-testing. This fixes a regression.

Will commit to the other affected branches shortly.

Regards

	Thomas

2016-07-22  Thomas Koenig  <tkoenig@gcc.gnu.org>

        PR fortran/71795
        * frontend-passes.c (combine_array_constructor):  Don't
        do anything if the expression is inside an array iterator.

2016-07-22  Thomas Koenig  <tkoenig@gcc.gnu.org>

        PR fortran/71795
        * gfortran.dg/constructor_50.f90:  New test.

Index: frontend-passes.c
===================================================================
--- frontend-passes.c	(Revision 238497)
+++ frontend-passes.c	(Arbeitskopie)
@@ -1255,6 +1255,11 @@ combine_array_constructor (gfc_expr *e)
   if (forall_level > 0)
     return false;
 
+  /* Inside an iterator, things can get hairy; we are likely to create
+     an invalid temporary variable.  */
+  if (iterator_level > 0)
+    return false;
+
   op1 = e->value.op.op1;
   op2 = e->value.op.op2;
 
! { dg-do run }
! PR 71795 - wrong result when putting an array constructor
! instide an iterator.
     program test

     implicit none
     integer :: i,n
     logical, dimension(1) :: ra
     logical :: rs
     integer, allocatable :: a(:)

     allocate ( a(1) )

     n = 1
     a = 2

     ra = (/ (any(a(i).eq.(/1,2,3/)) ,i=1,n) /)
     if (.not. all(ra)) call abort
     rs = any ( (/ (any(a(i).eq.(/1,2,3/)) ,i=1,n) /) )
     if (.not. rs) call abort
   end program test

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]