]> granicus.if.org Git - clang/commitdiff
Fix <rdar://problem/6243788> clang: Incorrect return statement for Blocks?
authorSteve Naroff <snaroff@apple.com>
Wed, 24 Sep 2008 22:26:48 +0000 (22:26 +0000)
committerSteve Naroff <snaroff@apple.com>
Wed, 24 Sep 2008 22:26:48 +0000 (22:26 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56590 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 3cadd526a7755f619073ba538f4e2e3c94ae8b94..df832b70dc74147ea3915fb43ce1a7a59c212577 100644 (file)
@@ -679,7 +679,9 @@ Sema::ActOnBlockReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp) {
   // the block from it.
   if (CurBlock->ReturnType == 0) {
     if (RetValExp) {
-      UsualUnaryConversions(RetValExp);
+      // Don't call UsualUnaryConversions(), since we don't want to do
+      // integer promotions here.
+      DefaultFunctionArrayConversion(RetValExp);
       CurBlock->ReturnType = RetValExp->getType().getTypePtr();
     } else
       CurBlock->ReturnType = Context.VoidTy.getTypePtr();
index 93511dbd7e35a19b477ad18ae6f04fb1711cd900..2110f2ce4529ede8296d1c5a9df73115a35d5ef9 100644 (file)
@@ -50,3 +50,23 @@ typedef int (^CL2)(void);
 CL2 foo2() {
   return ^{ return 1; }; // expected-error {{returning block that lives on the local stack}}
 }
+
+typedef unsigned int * uintptr_t;
+typedef char Boolean;
+typedef int CFBasicHash;
+
+#define INVOKE_CALLBACK2(P, A, B) (P)(A, B)
+
+typedef struct {
+    Boolean (^isEqual)(const CFBasicHash *, uintptr_t stack_value_or_key1, uintptr_t stack_value_or_key2, Boolean is_key);
+} CFBasicHashCallbacks;
+
+int foo3() {
+    CFBasicHashCallbacks cb;
+    
+    Boolean (*value_equal)(uintptr_t, uintptr_t) = 0;
+            
+    cb.isEqual = ^(const CFBasicHash *table, uintptr_t stack_value_or_key1, uintptr_t stack_value_or_key2, Boolean is_key) {
+       return (Boolean)(uintptr_t)INVOKE_CALLBACK2(value_equal, (uintptr_t)stack_value_or_key1, (uintptr_t)stack_value_or_key2);
+    };
+}