This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/61596] -Wunused-local-typedefs warns incorrectly on a typedef that's referenced indirectly
- From: "thakis at chromium dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 28 Jul 2014 01:52:46 +0000
- Subject: [Bug c++/61596] -Wunused-local-typedefs warns incorrectly on a typedef that's referenced indirectly
- Auto-submitted: auto-generated
- References: <bug-61596-4 at http dot gcc dot gnu dot org/bugzilla/>
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.