@@ -14160,7 +14160,8 @@ tsubst_copy (tree t, tree args, tsubst_f
len = TREE_VEC_LENGTH (expanded);
/* Set TREE_USED for the benefit of -Wunused. */
for (int i = 0; i < len; i++)
- TREE_USED (TREE_VEC_ELT (expanded, i)) = true;
+ if (DECL_P (TREE_VEC_ELT (expanded, i)))
+ TREE_USED (TREE_VEC_ELT (expanded, i)) = true;
}
if (expanded == error_mark_node)
@@ -0,0 +1,25 @@
+// PR c++/71442
+// { dg-do compile { target c++11 } }
+// { dg-options "-Wunused-variable" }
+
+struct C
+{
+ template<typename... Ts>
+ int operator()(Ts &&...)
+ {
+ return sizeof...(Ts);
+ }
+};
+
+int
+main ()
+{
+ C {} (1, 1L, 1LL, 1.0);
+ char a; // { dg-warning "unused variable" }
+ short b; // { dg-warning "unused variable" }
+ int c; // { dg-warning "unused variable" }
+ long d; // { dg-warning "unused variable" }
+ long long e; // { dg-warning "unused variable" }
+ float f; // { dg-warning "unused variable" }
+ double g; // { dg-warning "unused variable" }
+}