From patchwork Tue Mar 29 07:59:35 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Koenig X-Patchwork-Id: 88734 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id A9DC6B6EEE for ; Tue, 29 Mar 2011 18:59:50 +1100 (EST) Received: (qmail 16849 invoked by alias); 29 Mar 2011 07:59:45 -0000 Received: (qmail 16832 invoked by uid 22791); 29 Mar 2011 07:59:44 -0000 X-SWARE-Spam-Status: No, hits=-0.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from cc-smtpout2.netcologne.de (HELO cc-smtpout2.netcologne.de) (89.1.8.212) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 29 Mar 2011 07:59:39 +0000 Received: from cc-smtpin1.netcologne.de (cc-smtpin1.netcologne.de [89.1.8.201]) by cc-smtpout2.netcologne.de (Postfix) with ESMTP id A953312774; Tue, 29 Mar 2011 09:59:37 +0200 (CEST) Received: from [192.168.0.197] (xdsl-78-35-133-10.netcologne.de [78.35.133.10]) by cc-smtpin1.netcologne.de (Postfix) with ESMTPSA id 7BB9111E84; Tue, 29 Mar 2011 09:59:36 +0200 (CEST) Message-ID: <4D919167.6040704@netcologne.de> Date: Tue, 29 Mar 2011 09:59:35 +0200 From: Thomas Koenig User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.2.14) Gecko/20110221 SUSE/3.1.8 Thunderbird/3.1.8 MIME-Version: 1.0 To: "fortran@gcc.gnu.org" , gcc-patches Subject: [ patch, committed] Warn about array temporary creation in front end optimization Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hello world, I have committed the attached patch as obvious, revision 171653, after regression-testing. Thomas 2011-03-29 Thomas Koenig * frontend-passes.c (create_var): Warn about creating an array temporary if requested. 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. 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)