diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2013-01-08 23:17:51 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2013-01-08 23:17:51 +0000 |
commit | 9c0816f36d9012c5ed1445ed969fba5b60bcec01 (patch) | |
tree | 4eba9b6f0fbcc4f27f7ac237d44cd23d3489df50 /lib/Sema/SemaExpr.cpp | |
parent | 6a502c4430088fe3bac7b5886cd9425f7e306b63 (diff) |
objectiveC blocks: It is impractical to capture
struct variables with flexiable array members in
blocks (and lambdas). Issue error instead of
crashing in IRGen. // rdar://12655829
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171912 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExpr.cpp')
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 1704de6e95..b5630ecb12 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -10759,7 +10759,22 @@ bool Sema::tryCaptureVariable(VarDecl *Var, SourceLocation Loc, } return true; } - + // Prohibit prohibit structs with flexisble array members too. + // We cannot capture what is in the tail end of the struct. + if (const RecordType *VTTy = Var->getType()->getAs<RecordType>()) { + if (VTTy->getDecl()->hasFlexibleArrayMember()) { + if (BuildAndDiagnose) { + if (IsBlock) + Diag(Loc, diag::err_ref_flexarray_type); + else + Diag(Loc, diag::err_lambda_capture_flexarray_type) + << Var->getDeclName(); + Diag(Var->getLocation(), diag::note_previous_decl) + << Var->getDeclName(); + } + return true; + } + } // Lambdas are not allowed to capture __block variables; they don't // support the expected semantics. if (IsLambda && HasBlocksAttr) { |