diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-02-21 22:51:27 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-02-21 22:51:27 +0000 |
commit | b8389976b25ef35d49c1e76d3366fe01415dda0b (patch) | |
tree | 41191db8851eb11680fe48a1a78b157631d7fa0f /clang/test/CXX/expr/expr.prim/expr.prim.general/p4-0x.cpp | |
parent | ebea9aff0da1848d805d367f0c882e1a4188e284 (diff) | |
download | bcm5719-llvm-b8389976b25ef35d49c1e76d3366fe01415dda0b.tar.gz bcm5719-llvm-b8389976b25ef35d49c1e76d3366fe01415dda0b.zip |
In the conflict between C++11 [expr.prim.general]p4, which declares
that 'this' can be used in the brace-or-equal-initializer of a
non-static data member, and C++11 [expr.prim.lambda]p9, which says
that lambda expressions not in block scope can have no captures, side
fully with C++11 [expr.prim.general]p4 by allowing 'this' to be
captured within these initializers. This seems to be the intent of
non-static data member initializers.
llvm-svn: 151101
Diffstat (limited to 'clang/test/CXX/expr/expr.prim/expr.prim.general/p4-0x.cpp')
-rw-r--r-- | clang/test/CXX/expr/expr.prim/expr.prim.general/p4-0x.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.general/p4-0x.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.general/p4-0x.cpp index b976e1664e1..b9f0414e917 100644 --- a/clang/test/CXX/expr/expr.prim/expr.prim.general/p4-0x.cpp +++ b/clang/test/CXX/expr/expr.prim/expr.prim.general/p4-0x.cpp @@ -7,3 +7,14 @@ struct S { int arr[sizeof(this)]; // expected-error {{invalid use of 'this' outside of a nonstatic member function}} int sz = sizeof(this); // ok }; + +namespace CaptureThis { + struct X { + int n = 10; + int m = [&]{return n + 1; }(); + int o = [&]{return this->m + 1; }(); + int p = [&]{return [&](int x) { return this->m + x;}(o); }(); + }; + + X x; +} |