From 80390766bd24c78c10fe3a328a82a233ef46c7cb Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Thu, 16 Jun 2011 18:08:57 -0400 Subject: [PATCH] re PR c++/49251 ([C++0x][parameter pack expanding] unused parameter warning with unpacking empty tuples) PR c++/49251 * semantics.c (finish_id_expression): Mark even dependent variables as used. From-SVN: r175119 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/semantics.c | 5 ++++- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/g++.dg/cpp0x/variadic113.C | 20 ++++++++++++++++++++ 4 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic113.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6523c940623..a8baca2eb65 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2011-06-16 Jason Merrill + PR c++/49251 + * semantics.c (finish_id_expression): Mark even dependent + variables as used. + PR c++/49420 * error.c (dump_template_argument): Don't try to omit default template args from an argument pack. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 55f9519c43b..bad7acbb671 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -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) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6622a60311d..cc12e7bf279 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2011-06-16 Jason Merrill + PR c++/49251 + * g++.dg/cpp0x/variadic113.C: New. + PR c++/49420 * g++.dg/cpp0x/variadic112.C: New. diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic113.C b/gcc/testsuite/g++.dg/cpp0x/variadic113.C new file mode 100644 index 00000000000..3f1bb2ad04a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic113.C @@ -0,0 +1,20 @@ +// PR c++/49251 +// { dg-options "-std=c++0x -Wunused-parameter" } + +struct A {}; +template 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 ) { + sink( f(t)... ); +} + +int main() { + unpack_test( A(), indices<>() ); +} -- 2.30.2