forked from OSchip/llvm-project
put back diagnostics when flexible members are captured
in lambdas. llvm-svn: 171921
This commit is contained in:
parent
675444d5de
commit
14da440018
|
@ -4612,6 +4612,9 @@ let CategoryName = "Lambda Issue" in {
|
||||||
def err_lambda_capture_vm_type : Error<
|
def err_lambda_capture_vm_type : Error<
|
||||||
"variable %0 with variably modified type cannot be captured in "
|
"variable %0 with variably modified type cannot be captured in "
|
||||||
"a lambda expression">;
|
"a lambda expression">;
|
||||||
|
def err_lambda_capture_flexarray_type : Error<
|
||||||
|
"variable %0 with flexible array member cannot be captured in "
|
||||||
|
"a lambda expression">;
|
||||||
def err_lambda_impcap : Error<
|
def err_lambda_impcap : Error<
|
||||||
"variable %0 cannot be implicitly captured in a lambda with no "
|
"variable %0 cannot be implicitly captured in a lambda with no "
|
||||||
"capture-default specified">;
|
"capture-default specified">;
|
||||||
|
|
|
@ -10762,10 +10762,13 @@ bool Sema::tryCaptureVariable(VarDecl *Var, SourceLocation Loc,
|
||||||
// Prohibit structs with flexible array members too.
|
// Prohibit structs with flexible array members too.
|
||||||
// We cannot capture what is in the tail end of the struct.
|
// We cannot capture what is in the tail end of the struct.
|
||||||
if (const RecordType *VTTy = Var->getType()->getAs<RecordType>()) {
|
if (const RecordType *VTTy = Var->getType()->getAs<RecordType>()) {
|
||||||
if (VTTy->getDecl()->hasFlexibleArrayMember() && IsBlock) {
|
if (VTTy->getDecl()->hasFlexibleArrayMember()) {
|
||||||
if (BuildAndDiagnose) {
|
if (BuildAndDiagnose) {
|
||||||
if (IsBlock)
|
if (IsBlock)
|
||||||
Diag(Loc, diag::err_ref_flexarray_type);
|
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)
|
Diag(Var->getLocation(), diag::note_previous_decl)
|
||||||
<< Var->getDeclName();
|
<< Var->getDeclName();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
// RUN: %clang_cc1 -fsyntax-only -fblocks -verify %s
|
// RUN: %clang_cc1 -fsyntax-only -fblocks -verify -std=c++11 %s
|
||||||
// rdar://12655829
|
// rdar://12655829
|
||||||
|
|
||||||
void f() {
|
void f() {
|
||||||
struct { int x; int y[]; } a; // expected-note {{'a' declared here}}
|
struct { int x; int y[]; } a; // expected-note 2 {{'a' declared here}}
|
||||||
^{return a.x;}(); // expected-error {{cannot refer to declaration of structure variable with flexible array member inside block}}
|
^{return a.x;}(); // expected-error {{cannot refer to declaration of structure variable with flexible array member inside block}}
|
||||||
|
[] {return a.x;}(); // expected-error {{variable 'a' with flexible array member cannot be captured in a lambda expression}}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue