[cfe-commits] r56761 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/Sema/block-return.c
Steve Naroff
snaroff at apple.com
Sat Sep 27 17:13:36 PDT 2008
Author: snaroff
Date: Sat Sep 27 19:13:36 2008
New Revision: 56761
URL: http://llvm.org/viewvc/llvm-project?rev=56761&view=rev
Log:
Fix <rdar://problem/6252226> parser thinks block argument is undefined identifier in NSServices.m
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/Sema/block-return.c
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=56761&r1=56760&r2=56761&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Sat Sep 27 19:13:36 2008
@@ -366,9 +366,14 @@
}
// If we are parsing a block, check the block parameter list.
if (CurBlock) {
- for (unsigned i = 0, e = CurBlock->Params.size(); i != e; ++i)
- if (CurBlock->Params[i]->getIdentifier() == &II)
- D = CurBlock->Params[i];
+ BlockSemaInfo *BLK = CurBlock;
+ do {
+ for (unsigned i = 0, e = BLK->Params.size(); i != e && D == 0; ++i)
+ if (BLK->Params[i]->getIdentifier() == &II)
+ D = BLK->Params[i];
+ if (D)
+ break; // Found!
+ } while ((BLK = BLK->PrevBlockInfo)); // Look through any enclosing blocks.
}
if (D == 0) {
// Otherwise, this could be an implicitly declared function reference (legal
Modified: cfe/trunk/test/Sema/block-return.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/block-return.c?rev=56761&r1=56760&r2=56761&view=diff
==============================================================================
--- cfe/trunk/test/Sema/block-return.c (original)
+++ cfe/trunk/test/Sema/block-return.c Sat Sep 27 19:13:36 2008
@@ -77,4 +77,6 @@
void foo4() {
int (^xx)(const char *s) = ^(char *s) { return 1; }; // expected-warning {{incompatible block pointer types initializing 'int (^)(char *)', expected 'int (^)(char const *)'}}
int (*yy)(const char *s) = funk; // expected-warning {{incompatible pointer types initializing 'int (char *)', expected 'int (*)(char const *)'}}
+
+ int (^nested)(char *s) = ^(char *str) { void (^nest)(void) = ^(void) { printf("%s\n", str); }; next(); return 1; };
}
More information about the cfe-commits
mailing list