diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-01-26 01:26:44 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-01-26 01:26:44 +0000 |
commit | 7e71884ecb43e643b93094e5f832387bd7b3f6a8 (patch) | |
tree | c02783b57678a57e1822d347a9bcb07f0c65084f | |
parent | 8781b7ddedb59a5710ce4a83c50601f6982190d0 (diff) | |
download | bcm5719-llvm-7e71884ecb43e643b93094e5f832387bd7b3f6a8.tar.gz bcm5719-llvm-7e71884ecb43e643b93094e5f832387bd7b3f6a8.zip |
Correct r124242 making sure function chunk that gets diagnosed is really about the block.
Clairvoyance by John!
llvm-svn: 124264
-rw-r--r-- | clang/lib/Sema/SemaType.cpp | 5 | ||||
-rw-r--r-- | clang/test/Sema/block-return.c | 1 |
2 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 2a54bcc3afb..8ca1e008238 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -1622,7 +1622,10 @@ TypeSourceInfo *Sema::GetTypeForDeclarator(Declarator &D, Scope *S, if ((T->isArrayType() || T->isFunctionType()) && (D.getName().getKind() != UnqualifiedId::IK_ConversionFunctionId)) { unsigned diagID = diag::err_func_returning_array_function; - if (D.getContext() == Declarator::BlockLiteralContext) + // Last processing chunk in block context means this function chunk + // represents the block. + if (chunkIndex == 0 && + D.getContext() == Declarator::BlockLiteralContext) diagID = diag::err_block_returning_array_function; Diag(DeclType.Loc, diagID) << T->isFunctionType() << T; T = Context.IntTy; diff --git a/clang/test/Sema/block-return.c b/clang/test/Sema/block-return.c index 2eb51e79ccb..23dbbc2ce66 100644 --- a/clang/test/Sema/block-return.c +++ b/clang/test/Sema/block-return.c @@ -98,6 +98,7 @@ bptr foo5(int j) { int (*funcptr3[5])(long); int sz8 = sizeof(^int (*[5])(long) {return funcptr3;}); // expected-error {{block cannot return array type}} expected-warning {{incompatible pointer to integer conversion}} +int sz9 = sizeof(^int(*())()[3]{ }); // expected-error {{function cannot return array type}} void foo6() { int (^b)(int) __attribute__((noreturn)); |