// Origin PR c++/33255 // { dg-options "-Wunused" } <-- should trigger -Wunused-local-typedefs // { dg-do compile } void test_warn() { typedef int foo; // { dg-warning "locally defined but not used" } } struct S { typedef int T; S() {} S(int) {} }; template struct ST { typedef T type; ST (int) {} ST () {} }; template void test0_tmpl(void) { typedef struct ST foo; foo(2); } int test0(void) { test0_tmpl(); } void test1(void) { typedef int foo; ST a; } int test2(void) { typedef S foo; foo::T i = 0; return i; } template void test3_tmpl(void) { typedef struct ST foo; ST v; const foo __attribute__((unused))&var = v; } void test3(void) { test3_tmpl(); } void test4(void) { typedef int foo; int __attribute__((unused))vec[1] = {sizeof (foo)}; } void test5(void) { typedef int T0; typedef char T1; typedef int* T2; typedef unsigned T3; struct C0 { virtual void f(void) {}}; struct C1 : C0 {}; typedef C0 T4; int v0 = (T0) 2; char __attribute__((unused)) v1 = static_cast (0); if (reinterpret_cast (&v0)); unsigned* const c = 0; unsigned* __attribute__((unused))v2 = const_cast (c); C0 *__attribute__((unused))p0 = 0; C1 *p1 = 0; p0 = dynamic_cast (p1); } void test6(void) { struct C0 {}; typedef C0 foo; C0 *__attribute__((unused))v = new foo; } template struct S7 { void f() { typedef int foo; sizeof(foo); } }; template void test7(void) { typedef typename ST::T bar; // { dg-warning "locally defined but not used" } typedef typename ST::T foo; // We shouldn't warn for this one, as // it's used below. S7 v; } template void test8(void) { int f(S7); void g(int); typedef T foo; g(f(S7())); } int test9(void) { struct s { typedef int foo;}; // { dg-warning "locally defined but not used" } struct t { typedef int bar;}; t::bar b = 0; return b; }