]> granicus.if.org Git - clang/commitdiff
Correct r124242 making sure function chunk that gets diagnosed is really about the...
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Wed, 26 Jan 2011 01:26:44 +0000 (01:26 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Wed, 26 Jan 2011 01:26:44 +0000 (01:26 +0000)
Clairvoyance by John!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124264 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaType.cpp
test/Sema/block-return.c

index 2a54bcc3afbdc8d118c0fd934802b7073cd8946c..8ca1e008238b2ede585ebc5d6ab9a1afc48c9e10 100644 (file)
@@ -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;
index 2eb51e79ccb76a983604f9a0908f37ef9106a155..23dbbc2ce66d60106e912f36d0296c08d41bd238 100644 (file)
@@ -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));