aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Naroff <snaroff@apple.com>2008-09-28 00:13:36 +0000
committerSteve Naroff <snaroff@apple.com>2008-09-28 00:13:36 +0000
commit538afe30e4f9bfb338171be859d584e201dca2df (patch)
treeb073861343481a802060b7466ede274cfa245db4
parente4b5ee06153777c6899d20797dce1d4d236eb4bc (diff)
Fix <rdar://problem/6252226> parser thinks block argument is undefined identifier in NSServices.m
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@56761 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaExpr.cpp11
-rw-r--r--test/Sema/block-return.c2
2 files changed, 10 insertions, 3 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index e8b4d8cb4b..dfa53ac439 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -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
diff --git a/test/Sema/block-return.c b/test/Sema/block-return.c
index 6d660d1402..ba3a0d269f 100644
--- a/test/Sema/block-return.c
+++ b/test/Sema/block-return.c
@@ -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; };
}