]> granicus.if.org Git - clang/commitdiff
Change error "function cannot return array type" -> "blocks cannot return array type...
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 25 Jan 2011 23:16:33 +0000 (23:16 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 25 Jan 2011 23:16:33 +0000 (23:16 +0000)
Addresses rdar://8876238.

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

include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaType.cpp
test/Sema/block-return.c

index f33285c7d4f973fd93e336d77ad8c0d4a58ed4eb..9518ed91bfbf1c523ce8a10dec64075423f526a4 100644 (file)
@@ -3381,8 +3381,8 @@ def err_blocks_disable : Error<"blocks support disabled - compile with -fblocks"
 def err_expected_block_lbrace : Error<"expected '{' 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_block_returning_array_function : Error<
+  "block cannot return %select{array|function}0 type %1">;
 
 
 // CFString checking
index c8f7545602bcf46c94ee0519e5c59329ec982549..09ebbc085fe5fd830ddefe63fabf6d21e1d8d6fa 100644 (file)
@@ -1621,8 +1621,10 @@ TypeSourceInfo *Sema::GetTypeForDeclarator(Declarator &D, Scope *S,
       // For conversion functions, we'll diagnose this particular error later.
       if ((T->isArrayType() || T->isFunctionType()) &&
           (D.getName().getKind() != UnqualifiedId::IK_ConversionFunctionId)) {
-        Diag(DeclType.Loc, diag::err_func_returning_array_function) 
-          << T->isFunctionType() << T;
+        unsigned diagID = diag::err_func_returning_array_function;
+        if (D.getContext() == Declarator::BlockLiteralContext)
+          diagID = diag::err_block_returning_array_function;
+        Diag(DeclType.Loc, diagID) << T->isFunctionType() << T;
         T = Context.IntTy;
         D.setInvalidType(true);
       }
index 5741fc9c6df2a9c47d5f9fa76dc751dfd861f200..2eb51e79ccb76a983604f9a0908f37ef9106a155 100644 (file)
@@ -97,7 +97,7 @@ bptr foo5(int j) {
 }
 
 int (*funcptr3[5])(long);
-int sz8 = sizeof(^int (*[5])(long) {return funcptr3;}); // expected-error {{function cannot return array type}} expected-warning {{incompatible pointer to integer conversion}}
+int sz8 = sizeof(^int (*[5])(long) {return funcptr3;}); // expected-error {{block cannot return array type}} expected-warning {{incompatible pointer to integer conversion}}
 
 void foo6() {
   int (^b)(int) __attribute__((noreturn));