diff options
author | John McCall <rjmccall@apple.com> | 2013-03-20 01:53:00 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2013-03-20 01:53:00 +0000 |
commit | 3c581bf152e5ff054d5de91ee5cb347e3c8e6988 (patch) | |
tree | f2abb3af926180fe0680142eef2cdfc69993ab64 /clang/lib/Sema/SemaDecl.cpp | |
parent | be99cc3a3e67c79c966fdaac92efc8a0e6ca563e (diff) | |
download | bcm5719-llvm-3c581bf152e5ff054d5de91ee5cb347e3c8e6988.tar.gz bcm5719-llvm-3c581bf152e5ff054d5de91ee5cb347e3c8e6988.zip |
Don't look outside the innermost enclosing namespace when
performing unqualified lookup for a friend class declaration.
rdar://13393749
llvm-svn: 177473
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index b3edc5ef2af..1cffce08087 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -9467,6 +9467,8 @@ Decl *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, // shouldn't be diagnosing. LookupName(Previous, S); + // When declaring or defining a tag, ignore ambiguities introduced + // by types using'ed into this scope. if (Previous.isAmbiguous() && (TUK == TUK_Definition || TUK == TUK_Declaration)) { LookupResult::Filter F = Previous.makeFilter(); @@ -9477,6 +9479,27 @@ Decl *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, } F.done(); } + + // C++11 [namespace.memdef]p3: + // If the name in a friend declaration is neither qualified nor + // a template-id and the declaration is a function or an + // elaborated-type-specifier, the lookup to determine whether + // the entity has been previously declared shall not consider + // any scopes outside the innermost enclosing namespace. + // + // Does it matter that this should be by scope instead of by + // semantic context? + if (!Previous.empty() && TUK == TUK_Friend) { + DeclContext *EnclosingNS = SearchDC->getEnclosingNamespaceContext(); + LookupResult::Filter F = Previous.makeFilter(); + while (F.hasNext()) { + NamedDecl *ND = F.next(); + DeclContext *DC = ND->getDeclContext()->getRedeclContext(); + if (DC->isFileContext() && !EnclosingNS->Encloses(ND->getDeclContext())) + F.erase(); + } + F.done(); + } // Note: there used to be some attempt at recovery here. if (Previous.isAmbiguous()) |