summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-05-24 04:29:20 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-05-24 04:29:20 +0000
commitce4f608f86f3ba2ab7e75e0ac3ad94f7af1afa46 (patch)
tree6c7fa6fbd18f0a32452f548e1bf72ba2103147db
parente4260f911b80d3047b6ce949b58b5f93cf143951 (diff)
downloadbcm5719-llvm-ce4f608f86f3ba2ab7e75e0ac3ad94f7af1afa46.tar.gz
bcm5719-llvm-ce4f608f86f3ba2ab7e75e0ac3ad94f7af1afa46.zip
DR1152 / PR12931 / PR6177: A candidate function which requires binding a const
volatile reference to a temporary is not viable. My interpretation is that DR1152 was a bugfix, not a rule change for C++11, so this is not conditional on the language mode. This matches g++'s behavior. llvm-svn: 157370
-rw-r--r--clang/lib/Sema/SemaOverload.cpp2
-rw-r--r--clang/test/SemaCXX/overload-call.cpp22
2 files changed, 15 insertions, 9 deletions
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 2068006c29c..49170d6f327 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -4153,7 +4153,7 @@ TryReferenceInit(Sema &S, Expr *Init, QualType DeclType,
// qualifier.
// This is also the point where rvalue references and lvalue inits no longer
// go together.
- if (!isRValRef && !T1.isConstQualified())
+ if (!isRValRef && (!T1.isConstQualified() || T1.isVolatileQualified()))
return ICS;
// -- If the initializer expression
diff --git a/clang/test/SemaCXX/overload-call.cpp b/clang/test/SemaCXX/overload-call.cpp
index 2b5ebb962b6..615b10a4397 100644
--- a/clang/test/SemaCXX/overload-call.cpp
+++ b/clang/test/SemaCXX/overload-call.cpp
@@ -260,14 +260,12 @@ struct Z : X, Y { };
int& cvqual_subsume(X&); // expected-note{{candidate function}}
float& cvqual_subsume(const Y&); // expected-note{{candidate function}}
-int& cvqual_subsume2(const X&); // expected-note{{candidate function}}
-float& cvqual_subsume2(const volatile Y&); // expected-note{{candidate function}}
-
-Z get_Z();
+int& cvqual_subsume2(X&); // expected-note{{candidate function}}
+float& cvqual_subsume2(volatile Y&); // expected-note{{candidate function}}
void cvqual_subsume_test(Z z) {
cvqual_subsume(z); // expected-error{{call to 'cvqual_subsume' is ambiguous}}
- int& x = cvqual_subsume2(get_Z()); // expected-error{{call to 'cvqual_subsume2' is ambiguous}}
+ cvqual_subsume2(z); // expected-error{{call to 'cvqual_subsume2' is ambiguous}}
}
// Test overloading with cv-qualification differences in reference
@@ -444,10 +442,10 @@ namespace PR6078 {
namespace PR6177 {
struct String { String(char const*); };
- void f(bool const volatile&); // expected-note{{passing argument to parameter here}}
- void f(String);
+ void f(bool const volatile&);
+ int &f(String);
- void g() { f(""); } // expected-error{{volatile lvalue reference to type 'const volatile bool' cannot bind to a value of unrelated type 'const char [1]'}}
+ void g() { int &r = f(""); }
}
namespace PR7095 {
@@ -574,3 +572,11 @@ namespace PR12142 {
void fun(int (*x)[10]); // expected-note{{candidate function not viable: 1st argument ('const int (*)[10]') would lose const qualifier}}
void g() { fun((const int(*)[10])0); } // expected-error{{no matching function for call to 'fun'}}
}
+
+// DR1152: Take 'volatile' into account when handling reference bindings in
+// overload resolution.
+namespace PR12931 {
+ void f(const int &, ...);
+ void f(const volatile int &, int);
+ void g() { f(0, 0); }
+}
OpenPOWER on IntegriCloud