Hi! In the following example, the "context" struct provides types to a template class, "structure". The provided type is used to define a member variable. Yet G++ 4.8 claims: g++-mp-4.8 -std=c++11 -Wall bar.cc bar.cc: In function 'int main()': bar.cc:12:21: warning: typedef 'using type = int' locally defined but not used [-Wunused-local-typedefs] using type = int; ^ This is: g++-mp-4.8 (MacPorts gcc48 4.8-20120527_1) 4.8.0 20120527 (experimental) Copyright (C) 2012 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. The program is: template <typename C> struct structure { typename C::type val; }; int main() { struct context { using type = int; }; return structure<context>{42}.val; } Thanks!
Created attachment 27539 [details] Test case
Dodji, can we do something about this?
Yes, I am testing a patch for this.
A candidate patch was sent to http://gcc.gnu.org/ml/gcc-patches/2012-09/msg01492.html
Author: dodji Date: Fri Sep 28 12:21:33 2012 New Revision: 191828 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=191828 Log: PR c++/53551 - -Wunused-local-typedefs misses uses We don't record the use of a typedef when it's used through a typename. 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. Added: trunk/gcc/testsuite/g++.dg/warn/Wunused-local-typedefs-2.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/decl.c trunk/gcc/testsuite/ChangeLog
Fixed in trunk (4.8)