[cfe-commits] r124297 - in /cfe/trunk: lib/Sema/SemaOverload.cpp test/CXX/over/over.load/p2-0x.cpp

Douglas Gregor dgregor at apple.com
Wed Jan 26 09:47:49 PST 2011


Author: dgregor
Date: Wed Jan 26 11:47:49 2011
New Revision: 124297

URL: http://llvm.org/viewvc/llvm-project?rev=124297&view=rev
Log:
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.

Added:
    cfe/trunk/test/CXX/over/over.load/p2-0x.cpp   (with props)
Modified:
    cfe/trunk/lib/Sema/SemaOverload.cpp

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=124297&r1=124296&r2=124297&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed Jan 26 11:47:49 2011
@@ -681,7 +681,7 @@
     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 @@
   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.

Added: cfe/trunk/test/CXX/over/over.load/p2-0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/over/over.load/p2-0x.cpp?rev=124297&view=auto
==============================================================================
--- cfe/trunk/test/CXX/over/over.load/p2-0x.cpp (added)
+++ cfe/trunk/test/CXX/over/over.load/p2-0x.cpp Wed Jan 26 11:47:49 2011
@@ -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
+};

Propchange: cfe/trunk/test/CXX/over/over.load/p2-0x.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cfe/trunk/test/CXX/over/over.load/p2-0x.cpp
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: cfe/trunk/test/CXX/over/over.load/p2-0x.cpp
------------------------------------------------------------------------------
    svn:mime-type = text/plain





More information about the cfe-commits mailing list