From: Thomas Koenig Date: Fri, 22 Jul 2016 10:38:32 +0000 (+0000) Subject: re PR fortran/71795 (Two Bugs in array constructors (optimization)) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1603ebe016da010dcfe264901c4f9a07f9d89e63;p=gcc.git re PR fortran/71795 (Two Bugs in array constructors (optimization)) 2016-07-22 Thomas Koenig 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 PR fortran/71795 * gfortran.dg/constructor_50.f90: New test. From-SVN: r238638 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 54f87d474c1..ff12b56ec2e 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2016-07-22 Thomas Koenig + + PR fortran/71795 + * frontend-passes.c (combine_array_constructor): Don't + do anything if the expression is inside an array iterator. + 2016-07-22 Andre Vehreschild * expr.c (gfc_find_stat_co): Fixed whitespaces. diff --git a/gcc/fortran/frontend-passes.c b/gcc/fortran/frontend-passes.c index d4dee47ab75..d333c6882a4 100644 --- a/gcc/fortran/frontend-passes.c +++ b/gcc/fortran/frontend-passes.c @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 656a6c23dda..feb3236fef9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-07-22 Thomas Koenig + + PR fortran/71795 + * gfortran.dg/constructor_50.f90: New test. + 2016-07-22 Martin Liska PR gcov-profile/69028 diff --git a/gcc/testsuite/gfortran.dg/array_constructor_50.f90 b/gcc/testsuite/gfortran.dg/array_constructor_50.f90 new file mode 100644 index 00000000000..c22c980edde --- /dev/null +++ b/gcc/testsuite/gfortran.dg/array_constructor_50.f90 @@ -0,0 +1,21 @@ +! { 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