[Sema] Compare bad conversions in overload resolution.
authorGeorge Burgess IV <george.burgess.iv@gmail.com>
Wed, 7 Sep 2016 20:03:19 +0000 (20:03 +0000)
committerGeorge Burgess IV <george.burgess.iv@gmail.com>
Wed, 7 Sep 2016 20:03:19 +0000 (20:03 +0000)
commitfbad5b2f1b7dfd1c7e16252315e63c6b3ebb1cc3
tree974503dcf05fc04741e6be1c22e250f035f7cb9f
parent14f382065fd183bd5e4d78fa2d41f4faf9c7d576
[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
clang/include/clang/Basic/AttrDocs.td
clang/lib/Sema/SemaOverload.cpp
clang/test/CodeGen/overloadable.c
clang/test/SemaCXX/overload-call.cpp