[cfe-dev] Keyword warnings in libc++'s type_traits and other headers

Dimitry Andric dimitry at andric.com
Sun Dec 22 13:27:52 PST 2013


Hi,

I ran into a situation where a C++ program was compiled with -Wsystem-headers.  When I did this with clang 3.4 or trunk, I got the following keyword warnings:

In file included from include/algorithm:624:
include/type_traits:288:29: warning: keyword '__is_void' will be made available as an identifier for the remainder of the translation unit [-Wkeyword-compat]
template <class _Tp> struct __is_void       : public false_type {};
                           ^
include/type_traits:309:29: warning: keyword '__is_integral' will be made available as an identifier for the remainder of the translation unit [-Wkeyword-compat]
template <class _Tp> struct __is_integral                     : public false_type {};
                           ^
include/type_traits:333:29: warning: keyword '__is_floating_point' will be made available as an identifier for the remainder of the translation unit [-Wkeyword-compat]
template <class _Tp> struct __is_floating_point              : public false_type {};
                           ^
include/type_traits:352:29: warning: keyword '__is_pointer' will be made available as an identifier for the remainder of the translation unit [-Wkeyword-compat]
template <class _Tp> struct __is_pointer       : public false_type {};
                           ^
include/type_traits:432:8: warning: keyword '__is_function' will be made available as an identifier for the remainder of the translation unit [-Wkeyword-compat]
struct __is_function
      ^
include/type_traits:442:40: warning: keyword '__is_member_function_pointer' will be made available as an identifier for the remainder of the translation unit [-Wkeyword-compat]
template <class _Tp> struct            __is_member_function_pointer             : public false_type {};
                                      ^
include/type_traits:450:40: warning: keyword '__is_member_pointer' will be made available as an identifier for the remainder of the translation unit [-Wkeyword-compat]
template <class _Tp>            struct __is_member_pointer             : public false_type {};
                                      ^
include/type_traits:653:8: warning: keyword '__is_signed' will be made available as an identifier for the remainder of the translation unit [-Wkeyword-compat]
struct __is_signed : public ___is_signed<_Tp> {};
      ^
include/type_traits:668:8: warning: keyword '__is_unsigned' will be made available as an identifier for the remainder of the translation unit [-Wkeyword-compat]
struct __is_unsigned : public ___is_unsigned<_Tp> {};
      ^
9 warnings generated.

This seems to have been introduced with r196212 in clang by Alp Toker, but it is unfortunate the warning hits libc++. :-)  The cause is a bunch of Embarcadero keywords defined in clang's lib/Parse/ParseExpr.cpp, which are exactly the same as these libc++-internal identifers.

Is the attached patch acceptable as a workaround?

-Dimitry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: avoid-keywords-1.diff
Type: application/octet-stream
Size: 8572 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20131222/002093b5/attachment.obj>
-------------- next part --------------

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 203 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20131222/002093b5/attachment.sig>


More information about the cfe-dev mailing list