From patchwork Sun Apr 29 07:14:12 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Koenig X-Patchwork-Id: 155703 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 55714B6FD8 for ; Sun, 29 Apr 2012 17:14:42 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1336288483; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=qCivWVh W57MMPUSA6G6ai5CSr1o=; b=l40D1TQTSfUsbj3jcAr2V4ZoKFb8gGp2U/xlRX5 SX0AmnTNY6nFCelRV2PBGpkS0+M5rGWHBO+LKa9xlGb6vUxmnkgjNLS2eMhUUQjx G4ZU/zQ5A0gQDu+C/UTU06oYpCgiFtmxBw4xF+Ju+tYdnlzfFfKipx2S/MJYAyIC dw88= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=JzExxhqomtfXyNKhnkFzl4BRYLFQkAA5Gm2n9XkPzwtflKPQQl62/KNe0h5ChQ o5cpHADKwQgk0Pp4kvyCOJSvN6hIJmtwSQbtt8GfvasqIulHIyHOwi0IE2RTFe6j o47TQvrD26hrZKQlni8mRSkLCcbFW6z0/h/k5Pkpz1GU8=; Received: (qmail 6555 invoked by alias); 29 Apr 2012 07:14:31 -0000 Received: (qmail 6534 invoked by uid 22791); 29 Apr 2012 07:14:29 -0000 X-SWARE-Spam-Status: No, hits=-1.5 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_NO, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from cc-smtpout3.netcologne.de (HELO cc-smtpout3.netcologne.de) (89.1.8.213) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 29 Apr 2012 07:14:15 +0000 Received: from cc-smtpin3.netcologne.de (cc-smtpin3.netcologne.de [89.1.8.203]) by cc-smtpout3.netcologne.de (Postfix) with ESMTP id 4A50A121B3; Sun, 29 Apr 2012 09:14:14 +0200 (CEST) Received: from [192.168.0.111] (xdsl-78-35-138-196.netcologne.de [78.35.138.196]) by cc-smtpin3.netcologne.de (Postfix) with ESMTPSA id 258CC11DA8; Sun, 29 Apr 2012 09:14:12 +0200 (CEST) Message-ID: <4F9CEA44.1040208@netcologne.de> Date: Sun, 29 Apr 2012 09:14:12 +0200 From: Thomas Koenig User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.2.17) Gecko/20110414 SUSE/3.1.10 Thunderbird/3.1.10 MIME-Version: 1.0 To: "fortran@gcc.gnu.org" , gcc-patches Subject: [patch, fortran, committed] Fix PR 53148 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 as rev. 186942 after regression-testing. Will also commit to 4.7 in a few days. Thomas 2012-04-29 Thomas Koenig PR fortran/53148 * frontend-passes.c (create_var): If the statement has a label, put the label around the block. 2012-04-29 Thomas Koenig PR fortran/53148 * gfortran.dg/function_optimize_12.f90: New test. ! { dg-do run } ! { dg-options "-ffrontend-optimize" } ! PR 53148 - this used to cause wrong code because the label was ! placed after the statement assigning the new variables. program main integer :: n double precision x n = 3 goto 100 100 x = dble(n) + dble(n) if (x /= 6.d0) call abort end program main Index: frontend-passes.c =================================================================== --- frontend-passes.c (Revision 186549) +++ frontend-passes.c (Arbeitskopie) @@ -271,6 +271,16 @@ create_var (gfc_expr * e) inserted_block->ext.block.assoc = NULL; ns->code = *current_code; + + /* If the statement has a label, make sure it is transferred to + the newly created block. */ + + if ((*current_code)->here) + { + inserted_block->here = (*current_code)->here; + (*current_code)->here = NULL; + } + inserted_block->next = (*current_code)->next; changed_statement = &(inserted_block->ext.block.ns->code); (*current_code)->next = NULL;