From b29dbfa555e2a017a01be3bb626fa805725b77ae Mon Sep 17 00:00:00 2001 From: jason Date: Wed, 10 Feb 2010 22:45:07 +0000 Subject: [PATCH] PR c++/41896 * semantics.c (outer_lambda_capture_p): Use current_function_decl instead of current_class_type. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@156673 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/semantics.c | 5 +++-- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nested3.C | 12 ++++++++++++ 4 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nested3.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 11ec213bc8a..7a6e78a20cc 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,11 @@ 2010-02-10 Jason Merrill + PR c++/41896 + * semantics.c (outer_lambda_capture_p): Use current_function_decl + instead of current_class_type. + +2010-02-10 Jason Merrill + PR c++/42983, core issue 906 * method.c (defaultable_fn_check): Check virtualness. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index f8ced6fd549..796b789199b 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2714,8 +2714,9 @@ outer_lambda_capture_p (tree decl) { return (TREE_CODE (decl) == FIELD_DECL && LAMBDA_TYPE_P (DECL_CONTEXT (decl)) - && (!current_class_type - || !DERIVED_FROM_P (DECL_CONTEXT (decl), current_class_type))); + /* Using current_class_type here causes problems with uses in a + nested lambda-introducer; see 41896. */ + && DECL_CONTEXT (current_function_decl) != DECL_CONTEXT (decl)); } /* ID_EXPRESSION is a representation of parsed, but unprocessed, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1ddd7918295..b7ea3a29647 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2010-02-10 Jason Merrill + PR c++/41896 + * g++.dg/cpp0x/lambda/lambda-nested3.C: New. + PR c++/42983, core issue 906 * g++.dg/cpp0x/defaulted15.C: Add virtualness test. * g++.dg/cpp0x/defaulted9.C: Move virtual default outside class. diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nested3.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nested3.C new file mode 100644 index 00000000000..2cc6f964083 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-nested3.C @@ -0,0 +1,12 @@ +// PR c++/41896 +// { dg-options "-std=c++0x" } + +void nested_lambda() +{ + float val; + + [val]() + { + [val](){}; + }; +} -- 2.11.4.GIT