1 // PR c++/79548 - missing -Wunused-variable on a typedef'd variable
2 // in a function template
4 // { dg-options "-Wunused" }
7 #define UNUSED __attribute__ ((unused))
12 T t; // { dg-warning "unused variable" }
15 U u; // { dg-warning "unused variable" }
18 template void f_int<int>();
24 T *t = 0; // { dg-warning "unused variable" }
27 U *u = 0; // { dg-warning "unused variable" }
30 template void f_intptr<int>();
36 // The variable is marked unused.
43 template void f_var_unused<int>();
47 void f_var_type_unused ()
49 // The variable's type is marked unused.
50 T* UNUSED t = new T; // { dg-bogus "unused variable" "bug 79585" }
53 U* UNUSED u = new U; // { dg-bogus "unused variable" "bug 79585" }
56 U v = U (); // { dg-bogus "unused variable" "bug 79585" }
59 template void f_var_type_unused<int>();
67 T t; // { dg-warning "unused variable" }
70 U u; // { dg-warning "unused variable" }
73 template void f_A<A>();
85 template void f_A_unused<A>();
99 template void f_B<B>();
102 struct NonTrivialDtor { ~NonTrivialDtor (); };
105 void f_with_NonTrivialDtor ()
107 // Expect no warnings when instantiated on a type with a non-trivial
115 template void f_with_NonTrivialDtor<NonTrivialDtor>();
118 struct D { NonTrivialDtor b; };
123 // Same as f_with_NonTrivialDtor but with a class that has a member
124 // with a non-trivial dtor.
131 template void f_D<D>();
134 struct UNUSED DeclaredUnused { };
137 void f_with_unused ()
139 // Expect no warnings when instantiatiated on a type declared
140 // with attribute unused.
147 template void f_with_unused<DeclaredUnused>();