]> granicus.if.org Git - clang/commit
[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)
commit2cef254afa0c2c82d87d37e7e5d57788061d44a2
treefc336d149e1e188d0446b077e20da9a962946661
parent0e0dad3c51e7c02307ccff4613167868d30bd5a4
[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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@280847 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Basic/AttrDocs.td
lib/Sema/SemaOverload.cpp
test/CodeGen/overloadable.c
test/SemaCXX/overload-call.cpp