commit b2f47a386f7f605829f4f1f30d2c1d8e254ff9d7
Author: Jason Merrill <jason@redhat.com>
Date: Wed Jun 15 13:32:16 2011 -0400
PR c++/49251
* semantics.c (finish_id_expression): Mark even dependent
variables as used.
@@ -3196,7 +3196,10 @@ finish_id_expression (tree id_expression,
(or an instantiation thereof). */
if (TREE_CODE (decl) == VAR_DECL
|| TREE_CODE (decl) == PARM_DECL)
- return convert_from_reference (decl);
+ {
+ mark_used (decl);
+ return convert_from_reference (decl);
+ }
/* The same is true for FIELD_DECL, but we also need to
make sure that the syntax is correct. */
else if (TREE_CODE (decl) == FIELD_DECL)
new file mode 100644
@@ -0,0 +1,20 @@
+// PR c++/49251
+// { dg-options "-std=c++0x -Wunused-parameter" }
+
+struct A {};
+template <int> int f(A);
+
+template< int... Indices >
+struct indices {};
+
+template< class... Args >
+void sink( Args&&... ) {}
+
+template< class T, int... Indices >
+void unpack_test( T && t, indices<Indices...> ) {
+ sink( f<Indices>(t)... );
+}
+
+int main() {
+ unpack_test( A(), indices<>() );
+}