aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Sema/SemaOverload.cpp4
-rw-r--r--test/CXX/over/over.match/over.match.best/over.ics.rank/p3-0x.cpp26
2 files changed, 27 insertions, 3 deletions
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp
index d32ff86953..85ae6f7326 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/lib/Sema/SemaOverload.cpp
@@ -2966,7 +2966,7 @@ TryReferenceInit(Sema &S, Expr *&Init, QualType DeclType,
ICS.Standard.setToType(2, T1);
ICS.Standard.ReferenceBinding = true;
ICS.Standard.DirectBinding = true;
- ICS.Standard.RRefBinding = isRValRef;
+ ICS.Standard.RRefBinding = isRValRef && InitCategory.isRValue();
ICS.Standard.CopyConstructor = 0;
// Nothing more to do: the inaccessibility/ambiguity check for
@@ -3036,7 +3036,7 @@ TryReferenceInit(Sema &S, Expr *&Init, QualType DeclType,
ICS.Standard.DirectBinding =
S.getLangOptions().CPlusPlus0x ||
(InitCategory.isPRValue() && !T2->isRecordType());
- ICS.Standard.RRefBinding = isRValRef;
+ ICS.Standard.RRefBinding = isRValRef && InitCategory.isRValue();
ICS.Standard.CopyConstructor = 0;
return ICS;
}
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
index cff9e9709a..faff058a50 100644
--- 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
@@ -15,7 +15,7 @@ namespace std_example {
float &k2 = g2(f1());
float &l2 = g2(f2());
- // FIXME: We don't support ref-qualifiers set.
+ // FIXME: We don't support ref-qualifiers yet.
#if 0
struct A {
A& operator<<(int);
@@ -33,3 +33,27 @@ namespace std_example {
a.p();
#endif
}
+
+template<typename T>
+struct remove_reference {
+ typedef T type;
+};
+
+template<typename T>
+struct remove_reference<T&> {
+ typedef T type;
+};
+
+template<typename T>
+struct remove_reference<T&&> {
+ typedef T type;
+};
+
+namespace FunctionReferencesOverloading {
+ template<typename T> int &f(typename remove_reference<T>::type&); // expected-note{{candidate function [with T = int (&)(int)]}}
+ template<typename T> float &f(typename remove_reference<T>::type&&); // expected-note{{candidate function [with T = int (&)(int)]}}
+
+ void test_f(int (&func_ref)(int)) {
+ f<int (&)(int)>(func_ref); // expected-error{{call to 'f' is ambiguous}}
+ }
+}