summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-02-09 02:12:34 +0000
committerDouglas Gregor <dgregor@apple.com>2012-02-09 02:12:34 +0000
commit3d23f78852b9405585fa33070a9f06aa32f21de3 (patch)
treea529d16dfcb1d3e325a459c73cd9f549eea45640
parent12b0dabd315610d2ee855bdd56b151cb540ebd35 (diff)
downloadbcm5719-llvm-3d23f78852b9405585fa33070a9f06aa32f21de3.tar.gz
bcm5719-llvm-3d23f78852b9405585fa33070a9f06aa32f21de3.zip
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
-rw-r--r--clang/lib/Sema/SemaExpr.cpp1
-rw-r--r--clang/test/CXX/expr/expr.prim/expr.prim.lambda/p14.cpp17
2 files changed, 18 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 11468e86769..4db266b2edf 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -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
diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p14.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p14.cpp
index 4c876d7480d..10d1e927bfe 100644
--- a/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p14.cpp
+++ b/clang/test/CXX/expr/expr.prim/expr.prim.lambda/p14.cpp
@@ -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!");
+}
OpenPOWER on IntegriCloud