r212978 - In C++98, if an rvalue reference binds to a function lvalue (or an xvalue or an

Richard Smith richard-llvm at metafoo.co.uk
Mon Jul 14 12:54:06 PDT 2014


Author: rsmith
Date: Mon Jul 14 14:54:05 2014
New Revision: 212978

URL: http://llvm.org/viewvc/llvm-project?rev=212978&view=rev
Log:
In C++98, if an rvalue reference binds to a function lvalue (or an xvalue or an
array prvalue), treat that as a direct binding. Only the class prvalue case
needs to be excluded here; the rest are extensions anyway, so we can treat them
as we would in C++11.

Modified:
    cfe/trunk/lib/Sema/SemaOverload.cpp
    cfe/trunk/test/SemaCXX/overload-call.cpp

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=212978&r1=212977&r2=212978&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Mon Jul 14 14:54:05 2014
@@ -4336,7 +4336,7 @@ TryReferenceInit(Sema &S, Expr *Init, Qu
     // standard library implementors; therefore, we need the xvalue check here.
     ICS.Standard.DirectBinding =
       S.getLangOpts().CPlusPlus11 ||
-      (InitCategory.isPRValue() && !T2->isRecordType());
+      !(InitCategory.isPRValue() || T2->isRecordType());
     ICS.Standard.IsLvalueReference = !isRValRef;
     ICS.Standard.BindsToFunctionLvalue = T2->isFunctionType();
     ICS.Standard.BindsToRvalue = InitCategory.isRValue();

Modified: cfe/trunk/test/SemaCXX/overload-call.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/overload-call.cpp?rev=212978&r1=212977&r2=212978&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/overload-call.cpp (original)
+++ cfe/trunk/test/SemaCXX/overload-call.cpp Mon Jul 14 14:54:05 2014
@@ -592,10 +592,10 @@ void test5() {
 }
 
 namespace PR20218 {
-  void f(void (*const &)()); // expected-note{{candidate}}
-  void f(void (&&)()) = delete; // expected-note{{candidate}} expected-warning 2{{extension}}
-  void g(void (&&)()) = delete; // expected-note{{candidate}} expected-warning 2{{extension}}
-  void g(void (*const &)()); // expected-note{{candidate}}
+  void f(void (*const &)()); // expected-note 2{{candidate}}
+  void f(void (&&)()) = delete; // expected-note 2{{candidate}} expected-warning 2{{extension}}
+  void g(void (&&)()) = delete; // expected-note 2{{candidate}} expected-warning 2{{extension}}
+  void g(void (*const &)()); // expected-note 2{{candidate}}
 
   void x();
   typedef void (&fr)();
@@ -604,11 +604,7 @@ namespace PR20218 {
   void h() {
     f(x); // expected-error {{ambiguous}}
     g(x); // expected-error {{ambiguous}}
-
-    // OK! These ones try to copy-initialize a temporary of the reference's
-    // underlying type, which only works for the pointer case and not for the
-    // reference case.
-    f(y);
-    g(y);
+    f(y); // expected-error {{ambiguous}}
+    g(y); // expected-error {{ambiguous}}
   }
 }





More information about the cfe-commits mailing list