re PR c++/41920 ([C++0x] Invalid 'unused parameter' warning for parameters used in lambdas)

PR c++/41920
	* semantics.c (build_lambda_object): Call mark_used on captured
	variables.

From-SVN: r156085
This commit is contained in:
Jason Merrill 2010-01-20 16:30:28 -05:00 committed by Jason Merrill
parent e4672ccdb3
commit 1f4a7a481f
4 changed files with 18 additions and 0 deletions

View File

@ -1,5 +1,9 @@
2010-01-20 Jason Merrill <jason@redhat.com>
PR c++/41920
* semantics.c (build_lambda_object): Call mark_used on captured
variables.
PR c++/40750
* decl.c (grokdeclarator): Clear type_quals for a member function
declared using a typedef. Don't complain about adding cv-quals

View File

@ -5408,6 +5408,9 @@ build_lambda_object (tree lambda_expr)
tree field = TREE_PURPOSE (node);
tree val = TREE_VALUE (node);
if (DECL_P (val))
mark_used (val);
/* Mere mortals can't copy arrays with aggregate initialization, so
do some magic to make it work here. */
if (TREE_CODE (TREE_TYPE (field)) == ARRAY_TYPE)

View File

@ -1,5 +1,8 @@
2010-01-20 Jason Merrill <jason@redhat.com>
PR c++/41920
* g++.dg/cpp0x/lambda/lambda-warn1.C: New.
PR c++/40750
* g++.dg/parse/fn-typedef1.C: New.
* g++.dg/other/cv_quals.C: Adjust.

View File

@ -0,0 +1,8 @@
// PR c++/41920
// { dg-options "-std=c++0x -Wall -Wextra" }
int foo(int i)
{
auto bar = [=](){ return i; };
return bar();
}