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, committed] Warn about array temporary creation in front end optimization


Hello world,

I have committed the attached patch as obvious, revision 171653, after regression-testing.

Thomas

2011-03-29 Thomas Koenig <tkoenig@gcc.gnu.org>

	* frontend-passes.c (create_var):  Warn about creating an
	array temporary if requested.

2011-03-29 Thomas Koenig <tkoenig@gcc.gnu.org>

        * gfortran.dg/function_optimize_1.f90:  Add -Warray-temporaries,
        check for corresponding warning.

2011-03-29 Thomas Koenig <tkoenig@gcc.gnu.org>

        * frontend-passes.c (create_var):  Warn about creating an
        array temporary if requested.
Index: fortran/frontend-passes.c
===================================================================
--- fortran/frontend-passes.c	(Revision 171618)
+++ fortran/frontend-passes.c	(Arbeitskopie)
@@ -256,6 +256,8 @@ create_var (gfc_expr * e)
       result->ref->u.ar.type = AR_FULL;
       result->ref->u.ar.where = e->where;
       result->ref->u.ar.as = symbol->as;
+      if (gfc_option.warn_array_temp)
+	gfc_warning ("Creating array temporary at %L", &(e->where));
     }
 
   /* Generate the new assignment.  */
Index: testsuite/gfortran.dg/function_optimize_1.f90
===================================================================
--- testsuite/gfortran.dg/function_optimize_1.f90	(Revision 171618)
+++ testsuite/gfortran.dg/function_optimize_1.f90	(Arbeitskopie)
@@ -1,5 +1,5 @@
 ! { dg-do compile }
-! { dg-options "-O -fdump-tree-original" }
+! { dg-options "-O -fdump-tree-original -Warray-temporaries" }
 program main
   implicit none
   real, dimension(2,2) :: a, b, c, d
@@ -24,7 +24,8 @@ program main
 
   data a /2., 3., 5., 7./
   data b /11., 13., 17., 23./
-  write (unit=line, fmt='(4F7.2)') matmul(a,b) + matmul(a,b)
+  write (unit=line, fmt='(4F7.2)') matmul(a,b)  &
+       & + matmul(a,b)    ! { dg-warning "Creating array temporary" }
   z = sin(x) + cos(x) + sin(x) + cos(x)
   print *,z
   x = ext_func(a) + 23 + ext_func(a)

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