From patchwork Thu Sep 20 20:15:17 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 185481 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 0EAA92C0089 for ; Fri, 21 Sep 2012 06:15:52 +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=1348776953; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:From:To:Cc:Subject:Date:Message-ID:User-Agent: MIME-Version:Content-Type:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=uLEmu10g/FHNkw7qXPD8hkeEVS0=; b=K1s3Fw7ZCFDiLo7 xx1tjtggM/jg2SWhv6I9L/IvHH1dLZQe7CiKzKiXwgd9o9586mZBaTAwrb7Uylmw RhePtg3M3gm86nRZMRrmQX9j7XvO5zKc6UHpbclpwKHZr6LxkXBZNWgCnP4aHkRF ClfB3346KAjmD0Czgyg4ZOOPOhCU= 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:From:To:Cc:Subject:X-URL:Date:Message-ID:User-Agent:MIME-Version:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=CXvI45G6SK6zpuJyZfk17hY5zsqaXHszVSBhX4VFT0QVbQxeXk0apxh3Wqf23f mvyWPRW4rGNI1+R0yrlW6aZCfOOIvMh5YL23zNTAIGR4V/X/+LGsc5S5Ba6WHvtT VDScZQnqOVW40Um5wm2cE79nvdMzVbEtOKOMYBLJplRX8=; Received: (qmail 11520 invoked by alias); 20 Sep 2012 20:15:42 -0000 Received: (qmail 11505 invoked by uid 22791); 20 Sep 2012 20:15:37 -0000 X-SWARE-Spam-Status: No, hits=-6.2 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS 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; Thu, 20 Sep 2012 20:15:19 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q8KKFJV5012175 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 20 Sep 2012 16:15:19 -0400 Received: from localhost (ovpn-116-41.ams2.redhat.com [10.36.116.41]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q8KKFHU2027134 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 20 Sep 2012 16:15:18 -0400 Received: by localhost (Postfix, from userid 500) id 3AD9F29C051; Thu, 20 Sep 2012 22:15:17 +0200 (CEST) From: Dodji Seketeli To: GCC Patches Cc: Jason Merrill Subject: [PATCH] PR c++/53551 - -Wunused-local-typedefs misses uses X-URL: http://www.redhat.com Date: Thu, 20 Sep 2012 22:15:17 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) MIME-Version: 1.0 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 Hello, We don't record the use of a typedef when it's used through a typename. So on the example of the patch, g++ complains that the 'type' typedef is not used. Fixed thus. Tested on x86_64-unknown-linux-gnu against trunk. gcc/cp/ * decl.c (make_typename_type): Record the use of typedefs. gcc/testsuite/ * g++.dg/warn/Wunused-local-typedefs-2.C: New test. --- gcc/cp/decl.c | 4 +++- .../g++.dg/warn/Wunused-local-typedefs-2.C | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletions(-) create mode 100644 gcc/testsuite/g++.dg/warn/Wunused-local-typedefs-2.C diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 6b5b986..09550be 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -3326,7 +3326,9 @@ make_typename_type (tree context, tree name, enum tag_types tag_type, if (DECL_ARTIFICIAL (t) || !(complain & tf_keep_type_decl)) t = TREE_TYPE (t); - + + maybe_record_typedef_use (t); + return t; } diff --git a/gcc/testsuite/g++.dg/warn/Wunused-local-typedefs-2.C b/gcc/testsuite/g++.dg/warn/Wunused-local-typedefs-2.C new file mode 100644 index 0000000..073e253 --- /dev/null +++ b/gcc/testsuite/g++.dg/warn/Wunused-local-typedefs-2.C @@ -0,0 +1,20 @@ +// Origin PR c++/33255 +// { dg-options "-Wunused" } <-- should trigger -Wunused-local-typedefs +// { dg-do compile { target c++11 } } + +template +struct structure +{ + typename C::type val; +}; + +int +main() +{ + struct context + { + using type = int; + }; + + return structure{42}.val; +}