Ping: https://gcc.gnu.org/ml/gcc-patches/2019-10/msg00062.html
I was privately pointed at the Clang tests. The implementation
passes most of them. The one difference I noticed is that GCC
expands macros in the __has_builtin argument list while Clang
doesn't. Since this is in line with other similar built-ins
(e.g., __has_attribute) and since Clang has at least one bug
report about this, I left it as is and just raised PR 91961
for the record.
On 10/11/2019 09:23 AM, Martin Sebor wrote:
Ping: https://gcc.gnu.org/ml/gcc-patches/2019-10/msg00062.html
On 10/1/19 11:16 AM, Martin Sebor wrote:
Attached is an implementation of the __has_builtin special
preprocessor operator/macro analogous to __has_attribute and
(hopefully) compatible with the synonymous Clang feature (I
couldn't actually find tests for it in the Clang test suite
but if someone points me at them I'll verify it).
Tested on x86_64-linux.
Martin
PS I couldn't find an existing API to test whether a reserved
symbol like __builtin_offsetof is a function-like built-in so
I hardwired the tests for C and C++ into the new names_builtin_p
functions. I don't like this very much because the next time
such an operator is added there is nothing to remind us to update
the functions. Adding a flag to the c_common_reswords array would
solve the problem but at the expense of a linear search through
it. Does anyone have a suggestion for how to do this better?