From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22616 invoked by alias); 26 Oct 2010 22:33:14 -0000 Received: (qmail 22607 invoked by uid 22791); 26 Oct 2010 22:33:12 -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; Tue, 26 Oct 2010 22:33:06 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o9QMX5DN006600 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 26 Oct 2010 18:33:05 -0400 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id o9QMX4xV003700 for ; Tue, 26 Oct 2010 18:33:04 -0400 Message-ID: <4CC75720.5050004@redhat.com> Date: Wed, 27 Oct 2010 02:15:00 -0000 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.14) Gecko/20101020 Lightning/1.0b1 Shredder/3.0.10pre MIME-Version: 1.0 To: gcc-patches List Subject: RFA: fairly mechanical PATCH for EXPR_LOC_OR_HERE macro Content-Type: multipart/mixed; boundary="------------010907040003040202000306" Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2010-10/txt/msg02293.txt.bz2 This is a multi-part message in MIME format. --------------010907040003040202000306 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 270 While working on constexpr I noticed that I wanted a simple way to say "either EXPR_LOCATION or input_location", but there wasn't one at the time. So I added one, and changed all the other places that wanted it to use it. Tested x86_64-pc-linux-gnu. OK for trunk? --------------010907040003040202000306 Content-Type: text/x-patch; name="expr-loc-or-here.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="expr-loc-or-here.patch" Content-length: 7144 commit 7a25c303a16d3693e61a471461d9cb7da600ff36 Author: Jason Merrill Date: Tue Oct 26 14:38:00 2010 -0400 * tree.h (EXPR_LOC_OR_HERE): New macro. * builtins.c (c_strlen): Use it. * c-decl.c (build_enumerator): Likewise. * gimplify.c (internal_get_tmp_var): Likewise. (shortcut_cond_expr): Likewise. (gimplify_one_sizepos): Likewise. c-family/ * c-common.c (conversion_warning, warn_for_collisions_1): Use EXPR_LOC_OR_HERE. cp/ * decl.c (pop_switch): Use EXPR_LOC_OR_HERE. * typeck.c (convert_for_assignment): Likewise. diff --git a/gcc/builtins.c b/gcc/builtins.c index ca69efa..0e3d5e2 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -506,10 +506,7 @@ c_strlen (tree src, int only_value) && (only_value || !TREE_SIDE_EFFECTS (TREE_OPERAND (src, 0)))) return c_strlen (TREE_OPERAND (src, 1), only_value); - if (EXPR_HAS_LOCATION (src)) - loc = EXPR_LOCATION (src); - else - loc = input_location; + loc = EXPR_LOC_OR_HERE (src); src = string_constant (src, &offset_node); if (src == 0) diff --git a/gcc/c-decl.c b/gcc/c-decl.c index a06d073..bb7cf64 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -7499,9 +7499,8 @@ build_enumerator (location_t decl_loc, location_t loc, /* Set basis for default for next value. */ the_enum->enum_next_value - = build_binary_op - (EXPR_HAS_LOCATION (value) ? EXPR_LOCATION (value) : input_location, - PLUS_EXPR, value, integer_one_node, 0); + = build_binary_op (EXPR_LOC_OR_HERE (value), + PLUS_EXPR, value, integer_one_node, 0); the_enum->enum_overflow = tree_int_cst_lt (the_enum->enum_next_value, value); /* Now create a declaration for the enum value name. */ diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 2f205ad..95ab32a 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -1859,8 +1859,7 @@ conversion_warning (tree type, tree expr) int i; const int expr_num_operands = TREE_OPERAND_LENGTH (expr); tree expr_type = TREE_TYPE (expr); - location_t loc = EXPR_HAS_LOCATION (expr) - ? EXPR_LOCATION (expr) : input_location; + location_t loc = EXPR_LOC_OR_HERE (expr); if (!warn_conversion && !warn_sign_conversion) return; @@ -2293,8 +2292,7 @@ warn_for_collisions_1 (tree written, tree writer, struct tlist *list, && (!only_writes || list->writer)) { warned_ids = new_tlist (warned_ids, written, NULL_TREE); - warning_at (EXPR_HAS_LOCATION (writer) - ? EXPR_LOCATION (writer) : input_location, + warning_at (EXPR_LOC_OR_HERE (writer), OPT_Wsequence_point, "operation on %qE may be undefined", list->expr); } diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index e513bc0..e5a1613 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -2868,10 +2868,7 @@ pop_switch (void) location_t switch_location; /* Emit warnings as needed. */ - if (EXPR_HAS_LOCATION (cs->switch_stmt)) - switch_location = EXPR_LOCATION (cs->switch_stmt); - else - switch_location = input_location; + switch_location = EXPR_LOC_OR_HERE (cs->switch_stmt); if (!processing_template_decl) c_do_switch_warnings (cs->cases, switch_location, SWITCH_STMT_TYPE (cs->switch_stmt), diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 160198b..6d061e7 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -7529,8 +7529,7 @@ convert_for_assignment (tree type, tree rhs, && TREE_CODE (TREE_TYPE (rhs)) != BOOLEAN_TYPE && (complain & tf_warning)) { - location_t loc = EXPR_HAS_LOCATION (rhs) - ? EXPR_LOCATION (rhs) : input_location; + location_t loc = EXPR_LOC_OR_HERE (rhs); warning_at (loc, OPT_Wparentheses, "suggest parentheses around assignment used as truth value"); diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 542c223..ea7e85a 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -587,10 +587,7 @@ internal_get_tmp_var (tree val, gimple_seq *pre_p, gimple_seq *post_p, mod = build2 (INIT_EXPR, TREE_TYPE (t), t, unshare_expr (val)); - if (EXPR_HAS_LOCATION (val)) - SET_EXPR_LOCATION (mod, EXPR_LOCATION (val)); - else - SET_EXPR_LOCATION (mod, input_location); + SET_EXPR_LOCATION (mod, EXPR_LOC_OR_HERE (val)); /* gimplify_modify_expr might want to reduce this further. */ gimplify_and_add (mod, pre_p); @@ -2620,8 +2617,7 @@ shortcut_cond_expr (tree expr) while (TREE_CODE (pred) == TRUTH_ANDIF_EXPR) { /* Keep the original source location on the first 'if'. */ - location_t locus = EXPR_HAS_LOCATION (expr) - ? EXPR_LOCATION (expr) : input_location; + location_t locus = EXPR_LOC_OR_HERE (expr); TREE_OPERAND (expr, 0) = TREE_OPERAND (pred, 1); /* Set the source location of the && on the second 'if'. */ if (EXPR_HAS_LOCATION (pred)) @@ -2643,8 +2639,7 @@ shortcut_cond_expr (tree expr) while (TREE_CODE (pred) == TRUTH_ORIF_EXPR) { /* Keep the original source location on the first 'if'. */ - location_t locus = EXPR_HAS_LOCATION (expr) - ? EXPR_LOCATION (expr) : input_location; + location_t locus = EXPR_LOC_OR_HERE (expr); TREE_OPERAND (expr, 0) = TREE_OPERAND (pred, 1); /* Set the source location of the || on the second 'if'. */ if (EXPR_HAS_LOCATION (pred)) @@ -2708,8 +2703,7 @@ shortcut_cond_expr (tree expr) /* If there was nothing else in our arms, just forward the label(s). */ if (!then_se && !else_se) return shortcut_cond_r (pred, true_label_p, false_label_p, - EXPR_HAS_LOCATION (expr) - ? EXPR_LOCATION (expr) : input_location); + EXPR_LOC_OR_HERE (expr)); /* If our last subexpression already has a terminal label, reuse it. */ if (else_se) @@ -2741,8 +2735,7 @@ shortcut_cond_expr (tree expr) jump_over_else = block_may_fallthru (then_); pred = shortcut_cond_r (pred, true_label_p, false_label_p, - EXPR_HAS_LOCATION (expr) - ? EXPR_LOCATION (expr) : input_location); + EXPR_LOC_OR_HERE (expr)); expr = NULL; append_to_statement_list (pred, &expr); @@ -7638,10 +7631,7 @@ gimplify_one_sizepos (tree *expr_p, gimple_seq *stmt_p) *expr_p = create_tmp_var (type, NULL); tmp = build1 (NOP_EXPR, type, expr); stmt = gimplify_assign (*expr_p, tmp, stmt_p); - if (EXPR_HAS_LOCATION (expr)) - gimple_set_location (stmt, EXPR_LOCATION (expr)); - else - gimple_set_location (stmt, input_location); + gimple_set_location (stmt, EXPR_LOC_OR_HERE (expr)); } } diff --git a/gcc/tree.h b/gcc/tree.h index 968a1bc..b799aaa 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -1598,6 +1598,7 @@ struct GTY(()) tree_constructor { (EXPR_P ((NODE)) ? (NODE)->exp.locus : UNKNOWN_LOCATION) #define SET_EXPR_LOCATION(NODE, LOCUS) EXPR_CHECK ((NODE))->exp.locus = (LOCUS) #define EXPR_HAS_LOCATION(NODE) (EXPR_LOCATION (NODE) != UNKNOWN_LOCATION) +#define EXPR_LOC_OR_HERE(NODE) (EXPR_HAS_LOCATION (NODE) ? (NODE)->exp.locus : input_location) #define EXPR_FILENAME(NODE) LOCATION_FILE (EXPR_CHECK ((NODE))->exp.locus) #define EXPR_LINENO(NODE) LOCATION_LINE (EXPR_CHECK (NODE)->exp.locus) --------------010907040003040202000306--