summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2013-12-18 23:02:36 +0000
committerDouglas Gregor <dgregor@apple.com>2013-12-18 23:02:36 +0000
commitd1e3ceb5ecb9a156f45d15ae8ccdcab0deb85590 (patch)
treebbcd02b25267e507c6976cb98a3136aa14ca32c7 /clang/lib/Sema/SemaExpr.cpp
parent64de91522fae01c4e202e92a8b5674c13ae72ba7 (diff)
downloadbcm5719-llvm-d1e3ceb5ecb9a156f45d15ae8ccdcab0deb85590.tar.gz
bcm5719-llvm-d1e3ceb5ecb9a156f45d15ae8ccdcab0deb85590.zip
Require the type of a by-copy capture to be complete before creating its field.
The problem here is more serious than the fix implies. Adding a field to a class updates the triviality bits for the class (among other things). Failing to require a complete type before adding the field meant that these updates don't happen in the well-formed case where the capture is an uninstantiated class template specialization, leading the lambda itself to be treated as having a trivial copy constructor when it shouldn't. Fixes <rdar://problem/15560464>. llvm-svn: 197623
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index fcd972436da..a1de4046e0f 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -11617,6 +11617,15 @@ static ExprResult addAsFieldToClosureType(Sema &S,
bool RefersToEnclosingLocal) {
CXXRecordDecl *Lambda = LSI->Lambda;
+ // Make sure that by-copy captures are of a complete type.
+ if (!DeclRefType->isDependentType() &&
+ !DeclRefType->isReferenceType() &&
+ S.RequireCompleteType(Loc, DeclRefType,
+ diag::err_capture_of_incomplete_type,
+ Var->getDeclName())) {
+ return ExprError();
+ }
+
// Build the non-static data member.
FieldDecl *Field
= FieldDecl::Create(S.Context, Lambda, Loc, Loc, 0, FieldType,
OpenPOWER on IntegriCloud