diff options
author | John McCall <rjmccall@apple.com> | 2009-12-10 09:41:52 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2009-12-10 09:41:52 +0000 |
commit | 9f54ad4381370c6b771424b53d219e661d6d6706 (patch) | |
tree | cf7e1c1bceaefab55c52fa3458005811e59d0185 /lib/Sema/SemaOverload.cpp | |
parent | 153c33ed957b135a366178c61bbe22b6b1362a2a (diff) |
Implement redeclaration checking and hiding semantics for using declarations. There
are a couple of O(n^2) operations in this, some analogous to the usual O(n^2)
redeclaration problem and some not. In particular, retroactively removing
shadow declarations when they're hidden by later decls is pretty unfortunate.
I'm not yet convinced it's worse than the alternative, though.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91045 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaOverload.cpp')
-rw-r--r-- | lib/Sema/SemaOverload.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index 9ca8d76783..522272ee7c 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -287,7 +287,8 @@ void ImplicitConversionSequence::DebugPrint() const { // signature), IsOverload returns false and MatchedDecl will be set to // point to the FunctionDecl for #2. Sema::OverloadKind -Sema::CheckOverload(FunctionDecl *New, LookupResult &Old, NamedDecl *&Match) { +Sema::CheckOverload(FunctionDecl *New, const LookupResult &Old, + NamedDecl *&Match) { for (LookupResult::iterator I = Old.begin(), E = Old.end(); I != E; ++I) { NamedDecl *OldD = (*I)->getUnderlyingDecl(); @@ -301,12 +302,18 @@ Sema::CheckOverload(FunctionDecl *New, LookupResult &Old, NamedDecl *&Match) { Match = *I; return Ovl_Match; } - } else if (!isa<UnresolvedUsingValueDecl>(OldD)) { + } else if (isa<UsingDecl>(OldD) || isa<TagDecl>(OldD)) { + // We can overload with these, which can show up when doing + // redeclaration checks for UsingDecls. + assert(Old.getLookupKind() == LookupUsingDeclName); + } else if (isa<UnresolvedUsingValueDecl>(OldD)) { + // Optimistically assume that an unresolved using decl will + // overload; if it doesn't, we'll have to diagnose during + // template instantiation. + } else { // (C++ 13p1): // Only function declarations can be overloaded; object and type // declarations cannot be overloaded. - // But we permit unresolved using value decls and diagnose the error - // during template instantiation. Match = *I; return Ovl_NonFunction; } |