From patchwork Wed Aug 21 15:57:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 268860 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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 8A3192C00B7 for ; Thu, 22 Aug 2013 01:58:12 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; q=dns; s=default; b=JOCubSLPWIQ4ADReu Xe1UCOxvE0+5g5oWWaUbC9kH4NDWy453FLhX/Bpcz/WeFPV7CL8ueY0O2wMR9Ugz 7/hSiW1aGyylVYgyulxnCx3RLT5VxaFZBj8VreYLoi7i7htMSwc8SVc46AzVx7iU ZcfbUcbxnaKD5fklrDFdT3DCMc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; s=default; bh=u3b56ZYsh00accHYZ1BpXBB PJNU=; b=FxUzrQplKykTZ8BH3xqqE0FqRVOOL6KtZBQTE4BMBHGcVufbToupcW4 icyYP1lDPJq3MpLiK9RG+bsgmuYgrF7zQ0yJz0qjq8ahIPkgwFY+UMIpHAWVkqCb Prjos8jJfjvLm9e3q49L5luxyzqAPxM36CTFrC5H/RW6EPcQER4o= Received: (qmail 10651 invoked by alias); 21 Aug 2013 15:58:05 -0000 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 Received: (qmail 10642 invoked by uid 89); 21 Aug 2013 15:58:05 -0000 X-Spam-SWARE-Status: No, score=-7.3 required=5.0 tests=AWL, BAYES_00, KHOP_THREADED, RCVD_IN_DNSWL_MED, RCVD_IN_HOSTKARMA_NO, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD, SPF_PASS, UNPARSEABLE_RELAY autolearn=ham version=3.3.2 Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Wed, 21 Aug 2013 15:58:04 +0000 Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r7LFw2TZ004269 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 21 Aug 2013 15:58:03 GMT Received: from userz7021.oracle.com (userz7021.oracle.com [156.151.31.85]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r7LFw0QN007835 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 21 Aug 2013 15:58:01 GMT Received: from abhmt115.oracle.com (abhmt115.oracle.com [141.146.116.67]) by userz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r7LFw0AD027080; Wed, 21 Aug 2013 15:58:00 GMT Received: from poldo4.casa (/79.47.193.107) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 21 Aug 2013 08:57:59 -0700 Message-ID: <5214E386.3030003@oracle.com> Date: Wed, 21 Aug 2013 17:57:58 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: Jason Merrill Subject: Re: [C++ Patch] PR 56130 References: <5214C491.9000005@oracle.com> In-Reply-To: <5214C491.9000005@oracle.com> X-Virus-Found: No Hi again, On 08/21/2013 03:45 PM, Paolo Carlini wrote: > Hi, > > this bug points out that we fail to emit deprecated warnings when > references are involved. Turns out that at the end of > finish_id_expression the VAR_DECL is wrapped in INDIRECT_REF. The > trivial patch below appears to work fine and should be pretty safe in > terms of false positives, because the warning is enabled by default. In fact, since we have an issue with *references* I think using REFERENCES_REF_P, per the below, would be more correct. Lightly tested so far, I'm booting and testing it. Thanks again, Paolo. ////////////////////////// Index: cp/semantics.c =================================================================== --- cp/semantics.c (revision 201902) +++ cp/semantics.c (working copy) @@ -3457,8 +3457,10 @@ finish_id_expression (tree id_expression, } } - if (TREE_DEPRECATED (decl)) - warn_deprecated_use (decl, NULL_TREE); + /* Handle references (c++/56130). */ + tree t = REFERENCE_REF_P (decl) ? TREE_OPERAND (decl, 0) : decl; + if (TREE_DEPRECATED (t)) + warn_deprecated_use (t, NULL_TREE); return decl; } Index: testsuite/g++.dg/warn/deprecated-7.C =================================================================== --- testsuite/g++.dg/warn/deprecated-7.C (revision 0) +++ testsuite/g++.dg/warn/deprecated-7.C (working copy) @@ -0,0 +1,17 @@ +// PR c++/56130 + +int g_nn; +int& g_n __attribute__((deprecated)) = g_nn; + +void f() +{ + int f_nn; + int& f_n __attribute__((deprecated)) = f_nn; + f_n = 1; // { dg-warning "'f_n' is deprecated" } +} + +int main() +{ + g_n = 1; // { dg-warning "'g_n' is deprecated" } + f(); +}