]> granicus.if.org Git - clang/commitdiff
In C++98, if an rvalue reference binds to a function lvalue (or an xvalue or an
authorRichard Smith <richard-llvm@metafoo.co.uk>
Mon, 14 Jul 2014 19:54:05 +0000 (19:54 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Mon, 14 Jul 2014 19:54:05 +0000 (19:54 +0000)
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.

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

lib/Sema/SemaOverload.cpp
test/SemaCXX/overload-call.cpp

index 5c9ee653fe91bbc27666a1202dfb671e251b11f6..6f42865c498ca8bb0c51fc23a3627b9e758a2926 100644 (file)
@@ -4336,7 +4336,7 @@ TryReferenceInit(Sema &S, Expr *Init, QualType DeclType,
     // 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();
index 01f70b6b23d8fc1fb66aefb853043da9b0d80332..19ce14481f8efe2f7c9300f6bfdac604a9f39f55 100644 (file)
@@ -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}}
   }
 }