When we create a non-static data member in the closure object for a

capture, make sure we actually add the field.

llvm-svn: 150135
This commit is contained in:
Douglas Gregor 2012-02-09 02:12:34 +00:00
parent 12b0dabd31
commit 3d23f78852
2 changed files with 18 additions and 0 deletions

View File

@ -9576,6 +9576,7 @@ static ExprResult captureInLambda(Sema &S, LambdaScopeInfo *LSI,
0, false, false);
Field->setImplicit(true);
Field->setAccess(AS_private);
Lambda->addDecl(Field);
// C++11 [expr.prim.lambda]p21:
// When the lambda-expression is evaluated, the entities that

View File

@ -29,3 +29,20 @@ void capture_with_default_args(CopyCtorDefault cct) {
}
// FIXME: arrays!
// Check for the expected non-static data members.
struct ExpectedLayout {
char a;
short b;
};
template<typename T> void capture(const T&);
void test_layout(char a, short b) {
auto x = [=] () -> void { // expected-error{{lambda expressions are not supported yet}}
capture(a);
capture(b);
};
static_assert(sizeof(x) == sizeof(ExpectedLayout), "Layout mismatch!");
}