From patchwork Sun Jun 3 22:04:24 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 162606 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 52C0BB6FCA for ; Mon, 4 Jun 2012 08:06:25 +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=1339365986; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Message-ID:Date:From:User-Agent:MIME-Version: To:CC:Subject:References:In-Reply-To:Content-Type:Mailing-List: Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:Sender:Delivered-To; bh=bpxpphRtI4zGkBkbrod6fsdWv+U=; b=wknYiGkbl42nD0DlsyA57uoZZ1oDa2t+LnIQZMvNpC1xow3VE7MhE2GoqPoGBs Q3pOfozBFpEE4bzx5TOUgR8wokJdf0ZjR2ZmpTkuZvtQhAtMgy1iiz3HHwFuVUey qT6dxqtFQJQayHP643vRZSuhdXAOjx/qXbTeH3dRSh1fU= 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:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:References:In-Reply-To:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=ybc8fT0CHgoF+EmpvusClA5R30K8kBm6KgrOGmLkcmPwxUDrOb3q1EcD7SRnAa RiFqaBwnMC3r2FDhXXiVlb/nCceh4XJnX6kYQsjwIL9F5/XUuYQdZDIEitN9efdA w7oGEd6ctUPZAHdXEBXu+b3htN07XyR2YyDl339w0N6M8=; Received: (qmail 11176 invoked by alias); 3 Jun 2012 22:06:19 -0000 Received: (qmail 11161 invoked by uid 22791); 3 Jun 2012 22:06:18 -0000 X-SWARE-Spam-Status: No, hits=-7.4 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, KHOP_THREADED, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_NO, RCVD_IN_HOSTKARMA_W, TW_CX, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from acsinet15.oracle.com (HELO acsinet15.oracle.com) (141.146.126.227) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 03 Jun 2012 22:06:04 +0000 Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by acsinet15.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id q53M5sts022881 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 3 Jun 2012 22:05:55 GMT Received: from acsmt358.oracle.com (acsmt358.oracle.com [141.146.40.158]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id q53M5qJm013743 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 3 Jun 2012 22:05:53 GMT Received: from abhmt116.oracle.com (abhmt116.oracle.com [141.146.116.68]) by acsmt358.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id q53M5pk5017758; Sun, 3 Jun 2012 17:05:51 -0500 Received: from [192.168.1.4] (/79.36.197.135) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 03 Jun 2012 15:05:50 -0700 Message-ID: <4FCBDF68.9090602@oracle.com> Date: Mon, 04 Jun 2012 00:04:24 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120421 Thunderbird/12.0 MIME-Version: 1.0 To: Jason Merrill CC: Dodji Seketeli , GCC Patches , Tom Tromey , Hans-Peter Nilsson , Greta Yorsh Subject: Re: [PATCH 2/2] Better system header location detection for built-in macro tokens References: <4FBA5A2F.9000206@redhat.com> <4FBD96EE.4040101@redhat.com> <4FCAD9B5.4060409@redhat.com> In-Reply-To: <4FCAD9B5.4060409@redhat.com> 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 On 06/03/2012 05:27 AM, Jason Merrill wrote: > On 06/02/2012 12:40 PM, Paolo Carlini wrote: >> That said, the tricks we are playing with the global input_location >> vs the loc we are passing around still confuse me quite a lot. >> Actually any *assignment* to input_location makes me a bit more >> nervous than I was already ;) Do you have any idea whether just >> passing down to build_x_modify_expr a different value for loc instead >> of assigning to input_location would also work for you? Maybe >> together with more throughly forwarding the loc from >> build_x_modify_expr itself to the build_min* functions (ie the >> project I mentioned above)?? > > We already pass to build_x_modify_expr the location that he is > assigning to input_location. I would guess that the issue in this > case is with the "in_system_header" macro, which uses input_location. > > I think the input_location hack here is OK until we improve our use of > explicit locations to make it unnecessary. Good. In any case, as far as I can see, the assignment Dodji is adding just before calling build_x_modify_expr doesn't change anything for "my" issue, which actually has to do with build_x_binary_op: if I apply to below, thus passing an actual loc to build_min_non_dep_loc, there is a diagnostic regression for the locations of libstdc++-v3/testsuite/20_util/bind_ref_neg.cc. If you see something obviously wrong somewhere, just let me know... Paolo. /////////////////// Index: typeck.c =================================================================== --- typeck.c (revision 188155) +++ typeck.c (working copy) @@ -2696,9 +2696,8 @@ finish_class_member_access_expr (tree object, tree BASELINK_QUALIFIED_P (member) = 1; orig_name = member; } - return build_min_non_dep (COMPONENT_REF, expr, - orig_object, orig_name, - NULL_TREE); + return build_min_non_dep_loc (UNKNOWN_LOCATION, COMPONENT_REF, expr, + orig_object, orig_name, NULL_TREE); } return expr; @@ -2763,7 +2762,7 @@ build_x_indirect_ref (location_t loc, tree expr, r rval = cp_build_indirect_ref (expr, errorstring, complain); if (processing_template_decl && rval != error_mark_node) - return build_min_non_dep (INDIRECT_REF, rval, orig_expr); + return build_min_non_dep_loc (loc, INDIRECT_REF, rval, orig_expr); else return rval; } @@ -3631,7 +3630,7 @@ build_x_binary_op (location_t loc, enum tree_code warn_about_parentheses (code, arg1_code, orig_arg1, arg2_code, orig_arg2); if (processing_template_decl && expr != error_mark_node) - return build_min_non_dep (code, expr, orig_arg1, orig_arg2); + return build_min_non_dep_loc (loc, code, expr, orig_arg1, orig_arg2); return expr; } @@ -3660,8 +3659,8 @@ build_x_array_ref (location_t loc, tree arg1, tree NULL_TREE, /*overload=*/NULL, complain); if (processing_template_decl && expr != error_mark_node) - return build_min_non_dep (ARRAY_REF, expr, orig_arg1, orig_arg2, - NULL_TREE, NULL_TREE); + return build_min_non_dep_loc (loc, ARRAY_REF, expr, orig_arg1, orig_arg2, + NULL_TREE, NULL_TREE); return expr; } @@ -4764,7 +4763,7 @@ build_x_unary_op (location_t loc, enum tree_code c } if (processing_template_decl && exp != error_mark_node) - exp = build_min_non_dep (code, exp, orig_expr, + exp = build_min_non_dep_loc (loc, code, exp, orig_expr, /*For {PRE,POST}{INC,DEC}REMENT_EXPR*/NULL_TREE); if (TREE_CODE (exp) == ADDR_EXPR) PTRMEM_OK_P (exp) = ptrmem; @@ -5624,8 +5623,8 @@ build_x_conditional_expr (location_t loc, tree ife expr = build_conditional_expr (ifexp, op1, op2, complain); if (processing_template_decl && expr != error_mark_node) { - tree min = build_min_non_dep (COND_EXPR, expr, - orig_ifexp, orig_op1, orig_op2); + tree min = build_min_non_dep_loc (loc, COND_EXPR, expr, + orig_ifexp, orig_op1, orig_op2); /* In C++11, remember that the result is an lvalue or xvalue. In C++98, lvalue_kind can just assume lvalue in a template. */ if (cxx_dialect >= cxx0x @@ -5742,7 +5741,8 @@ build_x_compound_expr (location_t loc, tree op1, t result = cp_build_compound_expr (op1, op2, complain); if (processing_template_decl && result != error_mark_node) - return build_min_non_dep (COMPOUND_EXPR, result, orig_op1, orig_op2); + return build_min_non_dep_loc (loc, COMPOUND_EXPR, result, + orig_op1, orig_op2); return result; } Index: tree.c =================================================================== --- tree.c (revision 188155) +++ tree.c (working copy) @@ -2086,7 +2086,7 @@ build_min (enum tree_code code, tree tt, ...) built. */ tree -build_min_non_dep (enum tree_code code, tree non_dep, ...) +build_min_non_dep_loc (location_t loc, enum tree_code code, tree non_dep, ...) { tree t; int length; @@ -2101,6 +2101,7 @@ tree non_dep = TREE_OPERAND (non_dep, 0); t = make_node (code); + SET_EXPR_LOCATION (t, loc); length = TREE_CODE_LENGTH (code); TREE_TYPE (t) = TREE_TYPE (non_dep); TREE_SIDE_EFFECTS (t) = TREE_SIDE_EFFECTS (non_dep); Index: decl2.c =================================================================== --- decl2.c (revision 188155) +++ decl2.c (working copy) @@ -407,8 +407,8 @@ grok_array_decl (location_t loc, tree array_expr, expr = build_array_ref (input_location, array_expr, index_exp); } if (processing_template_decl && expr != error_mark_node) - return build_min_non_dep (ARRAY_REF, expr, orig_array_expr, orig_index_exp, - NULL_TREE, NULL_TREE); + return build_min_non_dep_loc (loc, ARRAY_REF, expr, orig_array_expr, + orig_index_exp, NULL_TREE, NULL_TREE); return expr; } Index: cp-tree.h =================================================================== --- cp-tree.h (revision 188155) +++ cp-tree.h (working copy) @@ -5697,7 +5697,8 @@ extern bool builtin_valid_in_constant_expr_p (c extern tree build_min (enum tree_code, tree, ...); extern tree build_min_nt_loc (location_t, enum tree_code, ...); -extern tree build_min_non_dep (enum tree_code, tree, ...); +extern tree build_min_non_dep_loc (location_t, enum tree_code, + tree, ...); extern tree build_min_non_dep_call_vec (tree, tree, VEC(tree,gc) *); extern tree build_cplus_new (tree, tree, tsubst_flags_t); extern tree build_aggr_init_expr (tree, tree, tsubst_flags_t);