From 23360fe40929b6f731db12007a7b262e72e5e336 Mon Sep 17 00:00:00 2001 From: Thomas Koenig Date: Tue, 29 Mar 2011 07:58:54 +0000 Subject: [PATCH] function_optimize_1.f90: Add -Warray-temporaries, check for corresponding warning. 2011-03-29 Thomas Koenig * gfortran.dg/function_optimize_1.f90: Add -Warray-temporaries, check for corresponding warning. 2011-03-29 Thomas Koenig * frontend-passes.c (create_var): Warn about creating an array temporary if requested. From-SVN: r171653 --- gcc/fortran/ChangeLog | 7 ++++++- gcc/fortran/frontend-passes.c | 2 ++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/function_optimize_1.f90 | 5 +++-- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 95d9b78a0bd..4bb344d003a 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,7 +1,12 @@ +2011-03-29 Thomas Koenig + + * frontend-passes.c (create_var): Warn about creating an + array temporary if requested. + 2011-03-27 Thomas Koenig PR fortran/47065 - * frontend-passes (optimize_trim): Also follow references, except + * frontend-passes.c (optimize_trim): Also follow references, except when they are substring references or array references. 2011-03-27 Tobias Burnus diff --git a/gcc/fortran/frontend-passes.c b/gcc/fortran/frontend-passes.c index 2051b0c566d..6e59c37cdbc 100644 --- a/gcc/fortran/frontend-passes.c +++ b/gcc/fortran/frontend-passes.c @@ -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. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7b1a72ee8e4..071f9596777 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-03-29 Thomas Koenig + + * gfortran.dg/function_optimize_1.f90: Add -Warray-temporaries, + check for corresponding warning. + 2011-03-28 Jason Merrill * g++.dg/cpp0x/rv-deduce2.C: New. diff --git a/gcc/testsuite/gfortran.dg/function_optimize_1.f90 b/gcc/testsuite/gfortran.dg/function_optimize_1.f90 index eaa915fc871..b023121831b 100644 --- a/gcc/testsuite/gfortran.dg/function_optimize_1.f90 +++ b/gcc/testsuite/gfortran.dg/function_optimize_1.f90 @@ -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) -- 2.30.2