From patchwork Thu May 17 00:34:53 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 159795 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 981ECB6FB7 for ; Thu, 17 May 2012 10:36: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=1337819786; 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=KJbCJTqGO0WrSG6rdGEVM+uu+bU=; b=u9yZGOTE3BdGMShyL3bHKwMltlLSX+mh9J9Ip2hOBgqS0Rn/xADiRHI4usnZ7i W1i5j6/knoiaLTuBqSHTn7UOxggJK6w00l12Sh2+KX0k8YL4QWY8LwXUbDJ7PUfU eIq61+j4FuL2M6Kd81xu63VkoLJ32O0/oFu9+ufBaSjvY= 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=IPNy3D62djkHLxYnw4uemc4DxRlasCYlt5l/yBaYX6v/MxF36jpz1tfDxHjz8p sS5Pj8aFENlVwKBburIY2kNqmKzhUXPjdNYcC5LjBtaFGR1iGtwOKt/zSEWEaq8d I4r5Vhrv+RepS2O8/CI84L3zxzwIeY4aiE1KCa5aPuSz4=; Received: (qmail 32445 invoked by alias); 17 May 2012 00:36:23 -0000 Received: (qmail 32433 invoked by uid 22791); 17 May 2012 00:36:22 -0000 X-SWARE-Spam-Status: No, hits=-7.2 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, KHOP_THREADED, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_NO, RCVD_IN_HOSTKARMA_YE, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from rcsinet15.oracle.com (HELO rcsinet15.oracle.com) (148.87.113.117) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 17 May 2012 00:35:51 +0000 Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by rcsinet15.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id q4H0Zn9X014706 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 17 May 2012 00:35:50 GMT Received: from acsmt357.oracle.com (acsmt357.oracle.com [141.146.40.157]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id q4H0ZnA8023895 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 17 May 2012 00:35:49 GMT Received: from abhmt117.oracle.com (abhmt117.oracle.com [141.146.116.69]) by acsmt357.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id q4H0ZmLr030272; Wed, 16 May 2012 19:35:48 -0500 Received: from [192.168.1.4] (/79.36.30.134) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 16 May 2012 17:35:48 -0700 Message-ID: <4FB447AD.2060308@oracle.com> Date: Thu, 17 May 2012 02:34:53 +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: "gcc-patches@gcc.gnu.org" Subject: Re: [C++ Patch] PR 44516 References: <4FB042F7.1060802@oracle.com> <4FB064DE.1080907@redhat.com> <4FB07AF9.8050500@oracle.com> <4FB082F1.3020100@redhat.com> <4FB1072B.9030909@oracle.com> <4FB131DA.7050809@redhat.com> <4FB1388F.1020208@oracle.com> <4FB14313.8000001@redhat.com> <4FB1926F.1040100@oracle.com> <4FB2A630.2090003@redhat.com> <4FB2C307.6090509@oracle.com> <4FB2D47A.9020706@redhat.com> <4FB2DC57.8080100@oracle.com> <4FB2E89B.2090408@redhat.com> <4FB2ED4B.40204@oracle.com> <4FB326BB.10708@redhat.com> <4FB38767.5030202@oracle.com> <4FB3CA9D.1020800@redhat.com> In-Reply-To: <4FB3CA9D.1020800@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 Hi, On 05/16/2012 05:41 PM, Jason Merrill wrote: > On 05/16/2012 06:54 AM, Paolo Carlini wrote: >> isn't the diagnostic machinery able to cope with UNKNOWN_LOCATION? By >> default should be interpreted as input_location, no? > That would make sense to me; I don't know if it works that way now, > though. So, in the meanwhile we learned that it doesn't. I also carried out a simple practical experiment where I hacked my on going work 53371 and changed its "error (" to an "error_at (UNKNOWN_LOCATION, " and this is the change: this: 53371.C: In function ‘int main()’: 53371.C:11:15: error: cannot catch exceptions by rvalue reference } catch (int&&) { } ^ (the caret is below the first &, good enough, I guess) becomes: In function ‘int main()’: cc1plus: error: cannot catch exceptions by rvalue reference totally broken. Thus, it remains to decide whether we want to guard against this with something local to the build_x_* functions, like my LOC_OR_HERE trick, or with something like the patchlet p1 which I'm attaching below. Just let me know. > >> @@ -11968,7 +11968,8 @@ tsubst_qualified_id (tree qualified_id, tree >> args, >> if (dependent_scope_p (scope)) >> { >> if (is_template) >> - expr = build_min_nt (TEMPLATE_ID_EXPR, expr, template_args); >> + expr = build_min_nt_loc (UNKNOWN_LOCATION, TEMPLATE_ID_EXPR, >> + expr, template_args); > > Here we should be able to retain the location from the > TEMPLATE_ID_EXPR we took apart earlier. Ok. Something like p2 below? We are getting close... ;) Thanks, Paolo. ////////////////////////// Index: pt.c =================================================================== --- pt.c (revision 187588) +++ pt.c (working copy) @@ -11932,6 +11932,7 @@ tsubst_qualified_id (tree qualified_id, tree args, tree name; bool is_template; tree template_args; + location_t loc = UNKNOWN_LOCATION; gcc_assert (TREE_CODE (qualified_id) == SCOPE_REF); @@ -11940,6 +11941,7 @@ tsubst_qualified_id (tree qualified_id, tree args, if (TREE_CODE (name) == TEMPLATE_ID_EXPR) { is_template = true; + loc = EXPR_LOCATION (name); template_args = TREE_OPERAND (name, 1); if (template_args) template_args = tsubst_template_args (template_args, args, @@ -11968,7 +11970,7 @@ tsubst_qualified_id (tree qualified_id, tree args, if (dependent_scope_p (scope)) { if (is_template) - expr = build_min_nt (TEMPLATE_ID_EXPR, expr, template_args); + expr = build_min_nt_loc (loc, TEMPLATE_ID_EXPR, expr, template_args); return build_qualified_name (NULL_TREE, scope, expr, QUALIFIED_NAME_IS_TEMPLATE (qualified_id)); } Index: diagnostic.c =================================================================== --- diagnostic.c (revision 187588) +++ diagnostic.c (working copy) @@ -508,6 +508,13 @@ diagnostic_report_diagnostic (diagnostic_context * diagnostic_t orig_diag_kind = diagnostic->kind; const char *saved_format_spec; + /* Tolerate UNKNOWN_LOCATION and turn it to input_location. */ + if (location == UNKNOWN_LOCATION) + { + diagnostic->location = input_location; + location = input_location; + } + /* Give preference to being able to inhibit warnings, before they get reclassified to something else. */ if ((diagnostic->kind == DK_WARNING || diagnostic->kind == DK_PEDWARN)