[cfe-commits] r150135 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/CXX/expr/expr.prim/expr.prim.lambda/p14.cpp
Douglas Gregor
dgregor at apple.com
Wed Feb 8 18:12:35 PST 2012
Author: dgregor
Date: Wed Feb 8 20:12:34 2012
New Revision: 150135
URL: http://llvm.org/viewvc/llvm-project?rev=150135&view=rev
Log:
When we create a non-static data member in the closure object for a
capture, make sure we actually add the field.
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p14.cpp
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=150135&r1=150134&r2=150135&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Feb 8 20:12:34 2012
@@ -9576,6 +9576,7 @@
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
Modified: cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p14.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p14.cpp?rev=150135&r1=150134&r2=150135&view=diff
==============================================================================
--- cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p14.cpp (original)
+++ cfe/trunk/test/CXX/expr/expr.prim/expr.prim.lambda/p14.cpp Wed Feb 8 20:12:34 2012
@@ -29,3 +29,20 @@
}
// 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!");
+}
More information about the cfe-commits
mailing list