aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-01-26 17:47:49 +0000
committerDouglas Gregor <dgregor@apple.com>2011-01-26 17:47:49 +0000
commit57c9f4f278fe15dc4964f2999486ffdbabce635c (patch)
treefca47f129e7fe2d0c666d26c46a9bab47984eaf9
parent0a9a6d68979619a621fedc5089674487f720f765 (diff)
Rvalue references for *this: allow functions to be overloaded based on
the presence and form of a ref-qualifier. Note that we do *not* yet implement the restriction in C++0x [over.load]p2 that requires either all non-static functions with a given parameter-type-list to have a ref-qualifier or none of them to have a ref-qualifier. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124297 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/SemaOverload.cpp5
-rw-r--r--test/CXX/over/over.load/p2-0x.cpp21
2 files changed, 24 insertions, 2 deletions
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp
index 602a118c3b..6c25893758 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/lib/Sema/SemaOverload.cpp
@@ -681,7 +681,7 @@ bool Sema::IsOverload(FunctionDecl *New, FunctionDecl *Old,
return true;
// If the function is a class member, its signature includes the
- // cv-qualifiers (if any) on the function itself.
+ // cv-qualifiers (if any) and ref-qualifier (if any) on the function itself.
//
// As part of this, also check whether one of the member functions
// is static, in which case they are not overloads (C++
@@ -692,7 +692,8 @@ bool Sema::IsOverload(FunctionDecl *New, FunctionDecl *Old,
CXXMethodDecl* NewMethod = dyn_cast<CXXMethodDecl>(New);
if (OldMethod && NewMethod &&
!OldMethod->isStatic() && !NewMethod->isStatic() &&
- OldMethod->getTypeQualifiers() != NewMethod->getTypeQualifiers())
+ (OldMethod->getTypeQualifiers() != NewMethod->getTypeQualifiers() ||
+ OldMethod->getRefQualifier() != NewMethod->getRefQualifier()))
return true;
// The signatures match; this is not an overload.
diff --git a/test/CXX/over/over.load/p2-0x.cpp b/test/CXX/over/over.load/p2-0x.cpp
new file mode 100644
index 0000000000..93ca0222a3
--- /dev/null
+++ b/test/CXX/over/over.load/p2-0x.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
+
+// Member function declarations with the same name and the same
+// parameter-type-list as well as mem- ber 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).
+
+class Y {
+ void h() &;
+ void h() const &;
+ void h() &&;
+ void i() &;
+ void i() const; // FIXME: expected an error here!
+
+ template<typename T> void f(T*) &;
+ template<typename T> void f(T*) &&;
+
+ template<typename T> void g(T*) &;
+ template<typename T> void g(T*); // FIXME: expected an error here
+};