From patchwork Tue Mar 25 07:58:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Koenig X-Patchwork-Id: 333306 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id E0B9714012F for ; Tue, 25 Mar 2014 18:58:50 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=FMZA97DhVgMsHzwqLCg8AmvaUks4Oerr1efOV3X3xxoPOE u1W77YCXab7lzmUyI5VMmtjlpsOtKf+8HWcvNLczci1dojO0Vog8adI3/NEH/CuR jSk2HHFncVDyA1KKMB5/SRA+gSSYC7SPtyDmtvQvLLqz9f1wLNR5GWSjNkGT0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=dBCYkjfdBbaTrvRfSUucd1OFy5Y=; b=L7zRa11qZGtY2f+cs/Gi pbGvRP5H6yYeogY6kG/ZF+3tMHi9AaLxQs51b/ZgR1SC2v+JJ4tnlZ1aWgcJiA4Y vr5zDoequVOJeLuYOLnrbw1OHdkQrH9hY9yFK4zgScE19ntrQFE6W8F7k9/820Ed x63cKRqcW0hwmcQWJsfh/Yk= Received: (qmail 2558 invoked by alias); 25 Mar 2014 07:58:43 -0000 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 Received: (qmail 2540 invoked by uid 89); 25 Mar 2014 07:58:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: cc-smtpout2.netcologne.de Received: from cc-smtpout2.netcologne.de (HELO cc-smtpout2.netcologne.de) (89.1.8.212) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 25 Mar 2014 07:58:41 +0000 Received: from cc-smtpin2.netcologne.de (cc-smtpin2.netcologne.de [89.1.8.202]) by cc-smtpout2.netcologne.de (Postfix) with ESMTP id B6B4F11F5D; Tue, 25 Mar 2014 08:58:37 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by cc-smtpin2.netcologne.de (Postfix) with ESMTP id A828D11DF9; Tue, 25 Mar 2014 08:58:37 +0100 (CET) Received: from [87.79.193.172] (helo=cc-smtpin2.netcologne.de) by localhost with ESMTP (eXpurgate 4.0.2) (envelope-from ) id 5331372d-0b31-7f0000012729-7f000001ddb5-1 for ; Tue, 25 Mar 2014 08:58:37 +0100 Received: from [192.168.178.20] (xdsl-87-79-193-172.netcologne.de [87.79.193.172]) (using TLSv1 with cipher ECDHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by cc-smtpin2.netcologne.de (Postfix) with ESMTPSA; Tue, 25 Mar 2014 08:58:35 +0100 (CET) Message-ID: <5331372B.4080004@netcologne.de> Date: Tue, 25 Mar 2014 08:58:35 +0100 From: Thomas Koenig User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: "fortran@gcc.gnu.org" , gcc-patches Subject: [patch, Fortran] Fix PR 60522 Hello world, the attached patch fixes the regression (after some thought of what might still be optimized, which isn't much :-) Regression-tested. OK for trunk? Thomas 2014-04-25 Thomas Koenig PR fortran/60522 * frontend-passes.c (cfe_code): Do not walk subtrees for WHERE. 2014-04-25 Thomas Koenig PR fortran/60522 * gfortran.dg/where_4.f90: New test case. Index: frontend-passes.c =================================================================== --- frontend-passes.c (Revision 208592) +++ frontend-passes.c (Arbeitskopie) @@ -627,12 +627,35 @@ cfe_expr_0 (gfc_expr **e, int *walk_subtrees, to insert statements as needed. */ static int -cfe_code (gfc_code **c, int *walk_subtrees ATTRIBUTE_UNUSED, - void *data ATTRIBUTE_UNUSED) +cfe_code (gfc_code **c, int *walk_subtrees, void *data ATTRIBUTE_UNUSED) { current_code = c; inserted_block = NULL; changed_statement = NULL; + + /* Do not do anything inside a WHERE statement; scalar assignments, BLOCKs + and allocation on assigment are prohibited inside WHERE, and finally + masking an expression would lead to wrong-code when replacing + + WHERE (a>0) + b = sum(foo(a) + foo(a)) + END WHERE + + with + + WHERE (a > 0) + tmp = foo(a) + b = sum(tmp + tmp) + END WHERE +*/ + + if ((*c)->op == EXEC_WHERE) + { + *walk_subtrees = 0; + return 0; + } + + return 0; }