https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61596
--- Comment #2 from thakis at chromium dot org --- Here's a similar example that doesn't need C++1y, regular C++11 is sufficient: thakis@ubu:~$ cat test.cc template <class T> void template_fun(T t) { typename T::Foo s3foo; // YYY (void)s3foo; } void template_fun_user() { struct Local { typedef int Foo; // XXX } p; template_fun(p); } thakis@ubu:~$ g++ -c test.cc -std=c++11 -Wall test.cc: In function ‘void template_fun_user()’: test.cc:8:17: warning: typedef ‘template_fun_user()::Local::Foo’ locally defined but not used [-Wunused-local-typedefs] typedef int Foo; ^ Maybe a possible fix is to store all typedefs that get this warning as candidates, and then emit warnings at the end of the translation unit for all candidates that are still unreferenced at that point.