[cfe-commits] r56590 - in /cfe/trunk: lib/Sema/SemaStmt.cpp test/Sema/block-return.c
Steve Naroff
snaroff at apple.com
Wed Sep 24 15:26:49 PDT 2008
Author: snaroff
Date: Wed Sep 24 17:26:48 2008
New Revision: 56590
URL: http://llvm.org/viewvc/llvm-project?rev=56590&view=rev
Log:
Fix <rdar://problem/6243788> clang: Incorrect return statement for Blocks?
Modified:
cfe/trunk/lib/Sema/SemaStmt.cpp
cfe/trunk/test/Sema/block-return.c
Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=56590&r1=56589&r2=56590&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Wed Sep 24 17:26:48 2008
@@ -679,7 +679,9 @@
// 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();
Modified: cfe/trunk/test/Sema/block-return.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/block-return.c?rev=56590&r1=56589&r2=56590&view=diff
==============================================================================
--- cfe/trunk/test/Sema/block-return.c (original)
+++ cfe/trunk/test/Sema/block-return.c Wed Sep 24 17:26:48 2008
@@ -50,3 +50,23 @@
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);
+ };
+}
More information about the cfe-commits
mailing list