[cfe-commits] r124264 - in /cfe/trunk: lib/Sema/SemaType.cpp test/Sema/block-return.c

Argyrios Kyrtzidis akyrtzi at gmail.com
Tue Jan 25 17:26:44 PST 2011


Author: akirtzidis
Date: Tue Jan 25 19:26:44 2011
New Revision: 124264

URL: http://llvm.org/viewvc/llvm-project?rev=124264&view=rev
Log:
Correct r124242 making sure function chunk that gets diagnosed is really about the block.
Clairvoyance by John!

Modified:
    cfe/trunk/lib/Sema/SemaType.cpp
    cfe/trunk/test/Sema/block-return.c

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=124264&r1=124263&r2=124264&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Tue Jan 25 19:26:44 2011
@@ -1622,7 +1622,10 @@
       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;

Modified: cfe/trunk/test/Sema/block-return.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/block-return.c?rev=124264&r1=124263&r2=124264&view=diff
==============================================================================
--- cfe/trunk/test/Sema/block-return.c (original)
+++ cfe/trunk/test/Sema/block-return.c Tue Jan 25 19:26:44 2011
@@ -98,6 +98,7 @@
 
 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));





More information about the cfe-commits mailing list