From: Douglas Gregor Date: Fri, 21 Jan 2011 16:48:38 +0000 (+0000) Subject: Add test for overload resolution's preference for binding an rvalue X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b13ede9f440f52ccfce046f1eba98679e9ffc0e6;p=clang Add test for overload resolution's preference for binding an rvalue 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 --- diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index f35a5b2893..478684b262 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -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 index 0000000000..cff9e9709a --- /dev/null +++ b/test/CXX/over/over.match/over.match.best/over.ics.rank/p3-0x.cpp @@ -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 +}