[PATCH] D13604: Fix to allow C conversions on arguments passed to functions with __attribute__((overloadable)) in C

George Burgess IV via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 9 13:43:22 PDT 2015


george.burgess.iv created this revision.
george.burgess.iv added a reviewer: rsmith.
george.burgess.iv added a subscriber: cfe-commits.

The following is legal in C, and illegal in C++:

```
void *getPtr();
void foo(char *c);
int main() {
	foo(getPtr());
}
```

Currently, we only allow C++ conversions in functions with `__attribute__((overloadable))` on them, even in C. So, if `foo` from the above example had this attribute (and overload(s)), the example would fail to compile as C. This patch teaches our overload logic that C conversions are legal if we’re overloading something in C.

As a neat side effect, this patch also potentially saves us a few bytes of heap each time we call `Sema::CheckAssignmentConstraints(SourceLocation, QualType, QualType)`, due to additions that mention `FixRHS`.

http://reviews.llvm.org/D13604

Files:
  include/clang/Sema/Overload.h
  include/clang/Sema/Sema.h
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaOverload.cpp
  test/Sema/overloadable.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13604.36986.patch
Type: text/x-patch
Size: 12919 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151009/2138f51e/attachment-0001.bin>


More information about the cfe-commits mailing list