diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-02-16 19:28:42 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-02-16 19:28:42 +0000 |
commit | c71e28c6a5a50d7eb00bd5f703d9a09b59412d6b (patch) | |
tree | 05a6e167e16dae9c1370e2c8224934f33b9ec1be | |
parent | ffed163be5e1e6304f738da90c6047c393e38565 (diff) |
When inside an Objective-C++ method, name lookup should look into the
interface for ivars before assuming that this is an unresolved
function name.
Fixes <rdar://problem/6590445>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64653 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 29 | ||||
-rw-r--r-- | test/SemaObjCXX/blocks.mm | 20 |
2 files changed, 35 insertions, 14 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 07079dbb7d..553c29e897 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -565,20 +565,6 @@ Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc, LookupResult Lookup = LookupParsedName(S, SS, Name, LookupOrdinaryName, false, true, Loc); - if (getLangOptions().CPlusPlus && (!SS || !SS->isSet()) && - HasTrailingLParen && Lookup.getKind() == LookupResult::NotFound) { - // We've seen something of the form - // - // identifier( - // - // and we did not find any entity by the name - // "identifier". However, this identifier is still subject to - // argument-dependent lookup, so keep track of the name. - return Owned(new (Context) UnresolvedFunctionNameExpr(Name, - Context.OverloadTy, - Loc)); - } - NamedDecl *D = 0; if (Lookup.isAmbiguous()) { DiagnoseAmbiguousLookup(Lookup, Name, Loc, @@ -621,6 +607,21 @@ Sema::ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc, return Owned(new (Context) ObjCSuperExpr(Loc, T)); } } + + if (getLangOptions().CPlusPlus && (!SS || !SS->isSet()) && + HasTrailingLParen && D == 0) { + // We've seen something of the form + // + // identifier( + // + // and we did not find any entity by the name + // "identifier". However, this identifier is still subject to + // argument-dependent lookup, so keep track of the name. + return Owned(new (Context) UnresolvedFunctionNameExpr(Name, + Context.OverloadTy, + Loc)); + } + if (D == 0) { // Otherwise, this could be an implicitly declared function reference (legal // in C90, extension in C99). diff --git a/test/SemaObjCXX/blocks.mm b/test/SemaObjCXX/blocks.mm index a792006922..34f75a023d 100644 --- a/test/SemaObjCXX/blocks.mm +++ b/test/SemaObjCXX/blocks.mm @@ -24,3 +24,23 @@ void foo4(id (^objectCreationBlock)(int)) { void foo5(id (^x)(int)) { if (x) { } } + +// <rdar://problem/6590445> +@interface Foo { + @private + void (^_block)(void); +} +- (void)bar; +@end + +namespace N { + class X { }; + void foo(X); +} + +@implementation Foo +- (void)bar { + _block(); + foo(N::X()); // okay +} +@end |