]> granicus.if.org Git - clang/commitdiff
Add test for overload resolution's preference for binding an rvalue
authorDouglas Gregor <dgregor@apple.com>
Fri, 21 Jan 2011 16:48:38 +0000 (16:48 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 21 Jan 2011 16:48:38 +0000 (16:48 +0000)
reference to an rvalue rather than binding a const-qualified lvalue
reference to that rvalue.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123979 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaOverload.cpp
test/CXX/over/over.match/over.match.best/over.ics.rank/p3-0x.cpp [new file with mode: 0644]

index f35a5b28930e5845dbe6976bfc5218f4cc79f4a3..478684b2628eff517c912cad337d5d73e58ee3b0 100644 (file)
@@ -2434,9 +2434,9 @@ CompareStandardConversionSequences(Sema &S,
     //      implicit object parameter of a non-static member function declared
     //      without a ref-qualifier, and S1 binds an rvalue reference to an
     //      rvalue and S2 binds an lvalue reference.
-    // FIXME: We don't know if we're dealing with the implicit object parameter,
-    // or if the member function in this case has a ref qualifier.
-    // (Of course, we don't have ref qualifiers yet.)
+    // FIXME: Rvalue references. We don't know if we're dealing with the 
+    // implicit object parameter, or if the member function in this case has a 
+    // ref qualifier. (Of course, we don't have ref qualifiers yet.)
     if (SCS1.RRefBinding != SCS2.RRefBinding)
       return SCS1.RRefBinding ? ImplicitConversionSequence::Better
                               : ImplicitConversionSequence::Worse;
diff --git a/test/CXX/over/over.match/over.match.best/over.ics.rank/p3-0x.cpp b/test/CXX/over/over.match/over.match.best/over.ics.rank/p3-0x.cpp
new file mode 100644 (file)
index 0000000..cff9e97
--- /dev/null
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
+namespace std_example {
+  int i; 
+  int f1(); 
+  int&& f2(); 
+  int &g(const int &);
+  float &g(const int &&);
+  int &j = g(i); 
+  float &k = g(f1());
+  float &l = g(f2());
+
+  int &g2(const int &);
+  float &g2(int &&);
+  int &j2 = g2(i); 
+  float &k2 = g2(f1());
+  float &l2 = g2(f2());
+
+  // FIXME: We don't support ref-qualifiers set.
+#if 0
+  struct A { 
+    A& operator<<(int); 
+    void p() &; 
+    void p() &&;
+  };
+
+  A& operator<<(A&&, char); 
+  A() << 1; 
+  A() << 'c'; 
+  A a; 
+  a << 1; 
+  a << 'c'; 
+  A().p(); 
+  a.p();
+#endif
+}