summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/overload-call.cpp
diff options
context:
space:
mode:
authorGeorge Burgess IV <george.burgess.iv@gmail.com>2016-09-07 20:03:19 +0000
committerGeorge Burgess IV <george.burgess.iv@gmail.com>2016-09-07 20:03:19 +0000
commitfbad5b2f1b7dfd1c7e16252315e63c6b3ebb1cc3 (patch)
tree974503dcf05fc04741e6be1c22e250f035f7cb9f /clang/test/SemaCXX/overload-call.cpp
parent14f382065fd183bd5e4d78fa2d41f4faf9c7d576 (diff)
downloadbcm5719-llvm-fbad5b2f1b7dfd1c7e16252315e63c6b3ebb1cc3.tar.gz
bcm5719-llvm-fbad5b2f1b7dfd1c7e16252315e63c6b3ebb1cc3.zip
[Sema] Compare bad conversions in overload resolution.
r280553 introduced an issue where we'd emit ambiguity errors for code like: ``` void foo(int *, int); void foo(unsigned int *, unsigned int); void callFoo() { unsigned int i; foo(&i, 0); // ambiguous: int->unsigned int is worse than int->int, // but unsigned int*->unsigned int* is better than // int*->int*. } ``` This patch fixes this issue by changing how we handle ill-formed (but valid) implicit conversions. Candidates with said conversions now always rank worse than candidates without them, and two candidates are considered to be equally bad if they both have these conversions for the same argument. Additionally, this fixes a case in C++11 where we'd complain about an ambiguity in a case like: ``` void f(char *, int); void f(const char *, unsigned); void g() { f("abc", 0); } ``` ...Since conversion to char* from a string literal is considered ill-formed in C++11 (and deprecated in C++03), but we accept it as an extension. llvm-svn: 280847
Diffstat (limited to 'clang/test/SemaCXX/overload-call.cpp')
-rw-r--r--clang/test/SemaCXX/overload-call.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/overload-call.cpp b/clang/test/SemaCXX/overload-call.cpp
index 7eaf98b601c..3a01bf24b31 100644
--- a/clang/test/SemaCXX/overload-call.cpp
+++ b/clang/test/SemaCXX/overload-call.cpp
@@ -647,3 +647,14 @@ namespace PR20218 {
g(y); // expected-error {{ambiguous}}
}
}
+
+namespace StringLiteralToCharAmbiguity {
+ void f(char *, int);
+ void f(const char *, unsigned);
+ void g() { f("foo", 0); }
+#if __cplusplus <= 199711L
+ // expected-error@-2 {{call to 'f' is ambiguous}}
+ // expected-note@-5 {{candidate function}}
+ // expected-note@-5 {{candidate function}}
+#endif
+}
OpenPOWER on IntegriCloud