forked from OSchip/llvm-project
Don't allow blocks to be declared as returning an array. Radar 6441502
llvm-svn: 70277
This commit is contained in:
parent
56f2987a87
commit
d456c48568
|
@ -1551,6 +1551,8 @@ def err_goto_in_block : Error<
|
|||
"goto not allowed in block literal">;
|
||||
def err_return_in_block_expression : Error<
|
||||
"return not allowed in block expression literal">;
|
||||
def err_block_returns_array : Error<
|
||||
"block declared as returning an array">;
|
||||
|
||||
def err_ret_local_block : Error<
|
||||
"returning block that lives on the local stack">;
|
||||
|
|
|
@ -4726,6 +4726,12 @@ void Sema::ActOnBlockArguments(Declarator &ParamInfo, Scope *CurScope) {
|
|||
|| ParamInfo.getTypeObject(0).Kind != DeclaratorChunk::Function) {
|
||||
QualType T = GetTypeForDeclarator(ParamInfo, CurScope);
|
||||
|
||||
if (T->isArrayType()) {
|
||||
Diag(ParamInfo.getSourceRange().getBegin(),
|
||||
diag::err_block_returns_array);
|
||||
return;
|
||||
}
|
||||
|
||||
// The parameter list is optional, if there was none, assume ().
|
||||
if (!T->isFunctionType())
|
||||
T = Context.getFunctionType(T, NULL, 0, 0, 0);
|
||||
|
|
|
@ -92,3 +92,6 @@ bptr foo5(int j) {
|
|||
return ^{ ^{ i=0; }(); }; // expected-error {{returning block that lives on the local stack}}
|
||||
return ^{ i=0; }; // expected-error {{returning block that lives on the local stack}}
|
||||
}
|
||||
|
||||
int (*funcptr3[5])(long);
|
||||
int sz8 = sizeof(^int (*[5])(long) {return funcptr3;}); // expected-error {{block declared as returning an array}}
|
||||
|
|
Loading…
Reference in New Issue