Fix <rdar://problem/6252226> parser thinks block argument is undefined identifier in NSServices.m

llvm-svn: 56761
This commit is contained in:
Steve Naroff 2008-09-28 00:13:36 +00:00
parent 843fe14fab
commit edec9ba58d
2 changed files with 10 additions and 3 deletions

View File

@ -366,9 +366,14 @@ Sema::ExprResult Sema::ActOnIdentifierExpr(Scope *S, SourceLocation Loc,
}
// 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

View File

@ -77,4 +77,6 @@ static int funk(char *s) {
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; };
}