]> granicus.if.org Git - clang/commitdiff
When we create a non-static data member in the closure object for a
authorDouglas Gregor <dgregor@apple.com>
Thu, 9 Feb 2012 02:12:34 +0000 (02:12 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 9 Feb 2012 02:12:34 +0000 (02:12 +0000)
capture, make sure we actually add the field.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150135 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/CXX/expr/expr.prim/expr.prim.lambda/p14.cpp

index 11468e86769d1de8f1a0002ab312fdf3c3ebf536..4db266b2edf4e8cdfbcc525de4e8dc7668fb0c46 100644 (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
index 4c876d7480de41ea276bf773ec31610638435391..10d1e927bfea5d958328bcff594c65d0d6c2147d 100644 (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!");
+}