Page MenuHomePhabricator

Fix to allow C conversions on arguments passed to functions with __attribute__((overloadable)) in C

Authored by george.burgess.iv on Oct 9 2015, 1:43 PM.



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

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

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.

Diff Detail


Event Timeline

george.burgess.iv retitled this revision from to Fix to allow C conversions on arguments passed to functions with __attribute__((overloadable)) in C.
george.burgess.iv updated this object.
george.burgess.iv added a reviewer: rsmith.
george.burgess.iv added a subscriber: cfe-commits.
srhines added a subscriber: srhines.Oct 9 2015, 3:12 PM
rsmith accepted this revision.Oct 9 2015, 3:21 PM
rsmith edited edge metadata.

Instead of FixRHS, I'd prefer either ConvertRHS or PerformConversion as your parameter name. Otherwise, LGTM, thanks!

1444–1445 ↗(On Diff #36986)

Fold these two 'if's together.

This revision is now accepted and ready to land.Oct 9 2015, 3:21 PM
This revision was automatically updated to reflect the committed changes.