From patchwork Tue Sep 3 15:10:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 272279 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 "www.sourceware.org", Issuer "StartCom Class 1 Primary Intermediate Server CA" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 4D1762C00A3 for ; Wed, 4 Sep 2013 01:10:34 +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:content-type; q=dns; s=default; b=U/CnQw9K95bTN06+e84XJKxw5BKaRFNbeoo8QsUof9C 6SxsEs80JNrwP1I7pyvuiiSJY/1qWY5cLXNDIvFK1aeC9PXTQv76KbyHzn1lFttu qxSJ6s1rU/pO+vR7vAQd3MDpfdejJH5hkV2hnjQo0P0ORgRBxAzVB/0stZpGD4E4 = 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:content-type; s=default; bh=zd5UUlgyGdcV4YgISplptVYPEX4=; b=MXeRNKJgMdn4UqC8i yK9eyg9usafkomkk8+AFrvSLfgeTRQt0gRBIyKIFpsUqueeKfqtcxt0rjhcBabJl 9w5yaH2tKxIuIIINgjfLTMSLOITLK7MtxebYoc7rqPzStW1bIt6qZ5b1UNv1L5HR kHN+xBVK3TbxQ8ZHSQ38yu7piQ= Received: (qmail 10686 invoked by alias); 3 Sep 2013 15:10:27 -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 10677 invoked by uid 89); 3 Sep 2013 15:10:26 -0000 Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Tue, 03 Sep 2013 15:10:26 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-7.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, RP_MATCHES_RCVD, SPF_PASS, UNPARSEABLE_RELAY autolearn=ham version=3.3.2 X-HELO: userp1040.oracle.com Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r83FANle013468 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 3 Sep 2013 15:10:24 GMT Received: from aserz7022.oracle.com (aserz7022.oracle.com [141.146.126.231]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r83FAM0H008126 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 3 Sep 2013 15:10:23 GMT Received: from abhmt101.oracle.com (abhmt101.oracle.com [141.146.116.53]) by aserz7022.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r83FAMqj013207; Tue, 3 Sep 2013 15:10:22 GMT Received: from poldo4.casa (/79.36.29.65) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Sep 2013 08:10:22 -0700 Message-ID: <5225FBDC.7010805@oracle.com> Date: Tue, 03 Sep 2013 17:10:20 +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: [C++ Patch] PR 58305 X-IsSubscribed: yes Hi, I think it's rather clear that we should warn in this case too, that is, when we have: ToBeDeprecated(); for a deprecated ToBeDeprecated type. Note however in my patchlet the check on the TREE_CODE: if I remove it, then we also warn for the lines x = e; and y = S::f; of g++.dg/parse/attr3.C. This seems wrong per our documentation, because those lines do not *name* the deprecated types E and F, but may make sense, for example clang++ *does* warn on those. Tested x86_64-linux. Thanks! Paolo. //////////////////////////// /cp 2013-09-03 Paolo Carlini PR c++/58305 * semantics.c (finish_expr_stmt): Maybe warn_deprecated_use. /testsuite 2013-09-03 Paolo Carlini PR c++/58305 * g++.dg/warn/deprecated-8.C: New. Index: cp/semantics.c =================================================================== --- cp/semantics.c (revision 202217) +++ cp/semantics.c (working copy) @@ -620,6 +620,9 @@ finish_expr_stmt (tree expr) { if (warn_sequence_point) verify_sequence_points (expr); + if (TREE_CODE (expr) == TARGET_EXPR + && TREE_DEPRECATED (TREE_TYPE (expr))) + warn_deprecated_use (TREE_TYPE (expr), NULL_TREE); expr = convert_to_void (expr, ICV_STATEMENT, tf_warning_or_error); } else if (!type_dependent_expression_p (expr)) Index: testsuite/g++.dg/warn/deprecated-8.C =================================================================== --- testsuite/g++.dg/warn/deprecated-8.C (revision 0) +++ testsuite/g++.dg/warn/deprecated-8.C (working copy) @@ -0,0 +1,10 @@ +// PR c++/58305 + +class ToBeDeprecated { +} __attribute__ ((deprecated ("deprecated!"))); + +int main() { + ToBeDeprecated(); // { dg-warning "'ToBeDeprecated' is deprecated" } + ToBeDeprecated x; // { dg-warning "'ToBeDeprecated' is deprecated" } + return 0; +}