[PATCH] add __has_builtin (PR 66970)

Martin Sebor msebor@gmail.com
Tue Oct 1 17:16:00 GMT 2019


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?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gcc-66970.diff
Type: text/x-patch
Size: 24607 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20191001/a8933970/attachment.bin>


More information about the Gcc-patches mailing list