From patchwork Mon Aug 16 20:45:38 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 61839 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 10B3BB6F0D for ; Tue, 17 Aug 2010 06:45:32 +1000 (EST) Received: (qmail 11513 invoked by alias); 16 Aug 2010 20:45:31 -0000 Received: (qmail 11499 invoked by uid 22791); 16 Aug 2010 20:45:30 -0000 X-SWARE-Spam-Status: No, hits=-6.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_TM, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 16 Aug 2010 20:45:26 +0000 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o7GKjOhH001918 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 16 Aug 2010 16:45:24 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o7GKjNsZ008381 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 16 Aug 2010 16:45:24 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id o7GKjdtH032553; Mon, 16 Aug 2010 22:45:39 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id o7GKjdXu032551; Mon, 16 Aug 2010 22:45:39 +0200 Date: Mon, 16 Aug 2010 22:45:38 +0200 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org, fortran@gcc.gnu.org Subject: [PATCH] Fix up Fortran line numbers (PR fortran/45186) Message-ID: <20100816204538.GB702@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-12-10) X-IsSubscribed: yes 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 Hi! As discussed on IRC and in the PR, this patch fixes Fortran line info by basically going back to what GCC 4.4 did. The FE doesn't pass input_location to all the various build*/fold_build*/build*_v functions/macros when it creates the trees, there are more than 1000 of such places. Ok for 4.5 (for which changing those 1000 places isn't really desirable)? What about 4.6? Bootstrapped/regtested on x86_64-linux and i686-linux. 2010-08-16 Jakub Jelinek PR fortran/45186 * trans.c (gfc_annotate_with_location): New function. (trans_code): Use it. Jakub --- gcc/fortran/trans.c.jj 2010-08-11 21:08:00.000000000 +0200 +++ gcc/fortran/trans.c 2010-08-16 12:37:45.000000000 +0200 @@ -1055,6 +1055,29 @@ gfc_set_backend_locus (locus * loc) input_location = loc->lb->location; } +/* Annotate statement or statement list T with location LOC. */ + +static void +gfc_annotate_with_location (tree t, location_t loc) +{ + if (TREE_CODE (t) == STATEMENT_LIST) + { + tree_stmt_iterator i; + + for (i = tsi_start (t); !tsi_end_p (i); tsi_next (&i)) + gfc_annotate_with_location (tsi_stmt (i), loc); + return; + } + if (TREE_CODE (t) == COMPOUND_EXPR) + { + gfc_annotate_with_location (TREE_OPERAND (t, 0), loc); + gfc_annotate_with_location (TREE_OPERAND (t, 1), loc); + } + if (TREE_CODE (t) == LABEL_EXPR || !TREE_SIDE_EFFECTS (t)) + return; + if (CAN_HAVE_LOCATION_P (t) && ! EXPR_HAS_LOCATION (t)) + SET_EXPR_LOCATION (t, loc); +} /* Translate an executable statement. The tree cond is used by gfc_trans_do. This static function is wrapped by gfc_trans_code_cond and @@ -1312,9 +1335,8 @@ trans_code (gfc_code * code, tree cond) if (res != NULL_TREE && ! IS_EMPTY_STMT (res)) { - if (TREE_CODE (res) != STATEMENT_LIST) - SET_EXPR_LOCATION (res, input_location); - + gfc_annotate_with_location (res, input_location); + /* Add the new statement to the block. */ gfc_add_expr_to_block (&block, res); }