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 for PR 56782


Hello world,

I committed the attached patch as obvious to fix the regression
with array constructors on trunk, after regression-testing.

Will commit to 4.8 next.

	Thomas

2013-04-08  Thomas Koenig  <tkoenig@gcc.gnu.org>

        PR fortran/56782
        * frontend-passes.c (callback_reduction):  Dont't do
        any simplification if there is only a single element
        which has an iterator.

2013-04-08  Thomas Koenig  <tkoenig@gcc.gnu.org>

        PR fortran/56782
        * gfortran.dg/array_constructor_44.f90:  New test.
Index: frontend-passes.c
===================================================================
--- frontend-passes.c	(Revision 197233)
+++ frontend-passes.c	(Arbeitskopie)
@@ -300,7 +300,12 @@ callback_reduction (gfc_expr **e, int *walk_subtre
 
   c = gfc_constructor_first (arg->value.constructor);
 
-  if (c == NULL)
+  /* Don't do any simplififcation if we have
+     - no element in the constructor or
+     - only have a single element in the array which contains an
+     iterator.  */
+
+  if (c == NULL || (c->iterator != NULL && gfc_constructor_next (c) == NULL))
     return 0;
 
   res = copy_walk_reduction_arg (c->expr, fn);
! { dg-do run }
! { dg-options "-ffrontend-optimize" }
! PR 56872 - wrong front-end optimization with a single constructor.
! Original bug report by Rich Townsend.
  integer :: k
  real :: s
  integer :: m
  s = 2.0
  m = 4
  res = SUM([(s**(REAL(k-1)/REAL(m-1)),k=1,m)])
  if (abs(res - 5.84732246) > 1e-6) call abort
  end

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