diff options
author | Jason Merrill <jason@redhat.com> | 2013-03-08 11:04:02 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2013-03-08 11:04:02 -0500 |
commit | 37fb0a98782876d242f27708e13723c4a2a5d8c7 (patch) | |
tree | d3fcb4bddef3180429388cfa791c683f2ed22e7e | |
parent | 0ef811d71e69f732716e92c81d157aa1c88e7e22 (diff) | |
download | gcc-37fb0a98782876d242f27708e13723c4a2a5d8c7.zip gcc-37fb0a98782876d242f27708e13723c4a2a5d8c7.tar.gz gcc-37fb0a98782876d242f27708e13723c4a2a5d8c7.tar.bz2 |
semantics.c (lambda_expr_this_capture): In unevaluated context, just return the nearest 'this'.
* semantics.c (lambda_expr_this_capture): In unevaluated context,
just return the nearest 'this'.
From-SVN: r196550
-rw-r--r-- | gcc/cp/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this12.C | 13 |
3 files changed, 21 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f9731a5..0aa5b4b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2013-03-08 Jason Merrill <jason@redhat.com> + * semantics.c (lambda_expr_this_capture): In unevaluated context, + just return the nearest 'this'. + PR c++/51494 PR c++/51884 PR c++/56222 diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index d11a4e4..233765a 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -9513,6 +9513,11 @@ lambda_expr_this_capture (tree lambda) if (!this_capture) { + /* In unevaluated context this isn't an odr-use, so just return the + nearest 'this'. */ + if (cp_unevaluated_operand) + return lookup_name (this_identifier); + error ("%<this%> was not captured for this lambda function"); result = error_mark_node; } diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this12.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this12.C new file mode 100644 index 0000000..ef573b1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-this12.C @@ -0,0 +1,13 @@ +// Uses of 'this' in unevaluated context are not odr-uses. +// { dg-do compile { target c++11 } } + +struct A +{ + int f() {} + int i; + + void foo() + { + [] () { sizeof(i); sizeof(f()); }; + } +}; |