diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-01-26 21:20:37 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-01-26 21:20:37 +0000 |
commit | b145ee6cc7d7db42ca4351ff3fe91f04e86a2f67 (patch) | |
tree | 3feec0884a90652a1ca8b00bfbf0d173d3fc5b93 /lib/Sema/SemaOverload.cpp | |
parent | 8ec14e605725a87991f622d63f547f877ba59fef (diff) |
Implement the restriction that a function with a ref-qualifier cannot
overload a function without a ref-qualifier (C++0x
[over.load]p2). This, apparently, completes the implementation of
rvalue references for *this.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124321 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaOverload.cpp')
-rw-r--r-- | lib/Sema/SemaOverload.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index 6d5eb8038d..0b01332700 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -694,8 +694,24 @@ bool Sema::IsOverload(FunctionDecl *New, FunctionDecl *Old, if (OldMethod && NewMethod && !OldMethod->isStatic() && !NewMethod->isStatic() && (OldMethod->getTypeQualifiers() != NewMethod->getTypeQualifiers() || - OldMethod->getRefQualifier() != NewMethod->getRefQualifier())) + OldMethod->getRefQualifier() != NewMethod->getRefQualifier())) { + if (!UseUsingDeclRules && + OldMethod->getRefQualifier() != NewMethod->getRefQualifier() && + (OldMethod->getRefQualifier() == RQ_None || + NewMethod->getRefQualifier() == RQ_None)) { + // C++0x [over.load]p2: + // - Member function declarations with the same name and the same + // parameter-type-list as well as member function template + // declarations with the same name, the same parameter-type-list, and + // the same template parameter lists cannot be overloaded if any of + // them, but not all, have a ref-qualifier (8.3.5). + Diag(NewMethod->getLocation(), diag::err_ref_qualifier_overload) + << NewMethod->getRefQualifier() << OldMethod->getRefQualifier(); + Diag(OldMethod->getLocation(), diag::note_previous_declaration); + } + return true; + } // The signatures match; this is not an overload. return false; |