]> granicus.if.org Git - clang/commit
[Sema] Relax overloading restrictions in C.
authorGeorge Burgess IV <george.burgess.iv@gmail.com>
Fri, 2 Sep 2016 22:59:57 +0000 (22:59 +0000)
committerGeorge Burgess IV <george.burgess.iv@gmail.com>
Fri, 2 Sep 2016 22:59:57 +0000 (22:59 +0000)
commit567da71b9bac96d6e87854f330139710fa2653a7
treef9d9683eb54509adfe92bba047525817a8eec537
parent89aa3ede8e973571becdb6314a861c6d2fc0a39f
[Sema] Relax overloading restrictions in C.

This patch allows us to perform incompatible pointer conversions when
resolving overloads in C. So, the following code will no longer fail to
compile (though it will still emit warnings, assuming the user hasn't
opted out of them):

```
void foo(char *) __attribute__((overloadable));
void foo(int) __attribute__((overloadable));

void callFoo() {
  unsigned char bar[128];
  foo(bar); // selects the char* overload.
}
```

These conversions are ranked below all others, so:

  A. Any other viable conversion will win out
  B. If we had another incompatible pointer conversion in the example
     above (e.g. `void foo(int *)`), we would complain about
     an ambiguity.

Differential Revision: https://reviews.llvm.org/D24113

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@280553 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Basic/AttrDocs.td
include/clang/Sema/Overload.h
lib/Sema/SemaExprCXX.cpp
lib/Sema/SemaOverload.cpp
test/CodeGen/builtins-systemz-zvector-error.c
test/CodeGen/overloadable.c
test/Sema/overloadable.c
test/Sema/pass-object-size.c
test/SemaOpenCL/event_t_overload.cl