re PR c++/50224 ([C++0x] bogus unused parameter warning (it is referenced in lambda))

PR c++/50224
	* semantics.c (finish_id_expression): Mark captured variables used.

From-SVN: r178277
This commit is contained in:
Jason Merrill 2011-08-30 00:30:58 -04:00 committed by Jason Merrill
parent e7b6bcf357
commit 809fbdce1c
4 changed files with 24 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2011-08-29 Jason Merrill <jason@redhat.com>
PR c++/50224
* semantics.c (finish_id_expression): Mark captured variables used.
2011-08-29 Jakub Jelinek <jakub@redhat.com>
Jason Merrill <jason@redhat.com>

View File

@ -2949,6 +2949,9 @@ finish_id_expression (tree id_expression,
tree lambda_expr = NULL_TREE;
tree initializer = convert_from_reference (decl);
/* Mark it as used now even if the use is ill-formed. */
mark_used (decl);
/* Core issue 696: "[At the July 2009 meeting] the CWG expressed
support for an approach in which a reference to a local
[constant] automatic variable in a nested class or lambda body

View File

@ -1,3 +1,8 @@
2011-08-29 Jason Merrill <jason@redhat.com>
PR c++/50224
* g++.dg/cpp0x/lambda/lambda-use2.C: New.
2011-08-29 Jakub Jelinek <jakub@redhat.com>
Jason Merrill <jason@redhat.com>

View File

@ -0,0 +1,11 @@
// PR c++/50224
// { dg-options "-std=c++0x -Wunused-parameter" }
struct T;
void m(T& t) // ERROR here
{
[&]{
t; // ``t`` is referenced here
};
}