[PATCH] D34779: Fix floating point promotions for overload purposes

Tim Northover via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 28 14:16:48 PDT 2017

t.p.northover created this revision.
Herald added a subscriber: mcrosier.

This has a couple of changes to how Clang determines whether a floating-point promotion has occurred for C++ (and `__attribute__((overloadable))`) purposes.

First, I think the special rules for C are based on a misconception. C99 referred to promotions to "long double" but it actually meant conversions, and the only real promotions that happened were the "float -> double" default argument promotion for varargs (and obviously nothing to do with overload resolution). C11 fixed this wording to remove all mention of promotions. So this patch makes all overload resolution follow C++ rules, which seems like the least surprising behaviour for __attribute__((overloadable)).

Second, this allows "half -> double" promotion unconditionally. Since half is a non-standard type there's a bit of guesswork here, but it seems like the most consistent extension of C++'s wording to that type (with special mention going to allowing "half -> float" too). It definitely seems reasonable that the decision should not depend on NativeHalfTypes.

Does the change look reasonable to others?




-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34779.104507.patch
Type: text/x-patch
Size: 9835 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170628/1dcc2734/attachment-0001.bin>

More information about the cfe-commits mailing list