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 | c83f9865a0dae4b290db05ee65e6e365651dc7b3 (patch) | |
| tree | 7292038016a256bb40acd3b98e37797c8f84df24 /clang/lib | |
| parent | 084e0628e085e8f56e8a42a15c0735525b1a3aa5 (diff) | |
| download | bcm5719-llvm-c83f9865a0dae4b290db05ee65e6e365651dc7b3.tar.gz bcm5719-llvm-c83f9865a0dae4b290db05ee65e6e365651dc7b3.zip | |
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.
llvm-svn: 124321
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Sema/SemaOverload.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index 6d5eb8038db..0b01332700c 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/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; |

