Use __is_identifier to detect Clang extensions instead of __has_extension.
When -pedantic-errors is specified `__has_extension(<feature>)` is always false when it would otherwise be true. This causes C++03 <atomic> to break along with other issues. This patch avoids the above problem by using __is_identifier(...) instead since it is not affected by -pedantic-errors. For example instead of checking for __has_extension(c_atomics) we now check `!__is_identifier(_Atomic)`, which is only true when _Atomic is not a keyword provided by the compiler. This patch applies similar changes to the detection logic for __decltype and __nullptr as well. Note that it does not apply this change to the C++03 `static_assert` macro since -Wc11-extensions warnings generated by expanding that macro will appear in user code, and will not be suppressed as part of a system header. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@291995 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -101,6 +101,8 @@
|
|||||||
#define __is_identifier(__x) 1
|
#define __is_identifier(__x) 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define __has_keyword(__x) !(__is_identifier(__x))
|
||||||
|
|
||||||
#if defined(__clang__)
|
#if defined(__clang__)
|
||||||
#define _LIBCPP_COMPILER_CLANG
|
#define _LIBCPP_COMPILER_CLANG
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
@@ -290,7 +292,7 @@ typedef __char32_t char32_t;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !(__has_feature(cxx_nullptr))
|
#if !(__has_feature(cxx_nullptr))
|
||||||
# if __has_extension(cxx_nullptr) && defined(_LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR)
|
# if (__has_extension(cxx_nullptr) || __has_keyword(__nullptr)) && defined(_LIBCPP_ABI_ALWAYS_USE_CXX11_NULLPTR)
|
||||||
# define nullptr __nullptr
|
# define nullptr __nullptr
|
||||||
# else
|
# else
|
||||||
# define _LIBCPP_HAS_NO_NULLPTR
|
# define _LIBCPP_HAS_NO_NULLPTR
|
||||||
@@ -741,7 +743,7 @@ template <unsigned> struct __static_assert_check {};
|
|||||||
|
|
||||||
#ifdef _LIBCPP_HAS_NO_DECLTYPE
|
#ifdef _LIBCPP_HAS_NO_DECLTYPE
|
||||||
// GCC 4.6 provides __decltype in all standard modes.
|
// GCC 4.6 provides __decltype in all standard modes.
|
||||||
#if !__is_identifier(__decltype) || _GNUC_VER >= 406
|
#if __has_keyword(__decltype) || _GNUC_VER >= 406
|
||||||
# define decltype(__x) __decltype(__x)
|
# define decltype(__x) __decltype(__x)
|
||||||
#else
|
#else
|
||||||
# define decltype(__x) __typeof__(__x)
|
# define decltype(__x) __typeof__(__x)
|
||||||
@@ -970,7 +972,7 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
|
|||||||
#define _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
|
#define _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if __has_feature(cxx_atomic) || __has_extension(c_atomic)
|
#if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic)
|
||||||
#define _LIBCPP_HAS_C_ATOMIC_IMP
|
#define _LIBCPP_HAS_C_ATOMIC_IMP
|
||||||
#elif _GNUC_VER > 407
|
#elif _GNUC_VER > 407
|
||||||
#define _LIBCPP_HAS_GCC_ATOMIC_IMP
|
#define _LIBCPP_HAS_GCC_ATOMIC_IMP
|
||||||
|
|||||||
@@ -13,6 +13,11 @@
|
|||||||
|
|
||||||
#include <ciso646> // Get STL specific macros like _LIBCPP_VERSION
|
#include <ciso646> // Get STL specific macros like _LIBCPP_VERSION
|
||||||
|
|
||||||
|
#if defined(__GNUC__)
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wvariadic-macros"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define TEST_CONCAT1(X, Y) X##Y
|
#define TEST_CONCAT1(X, Y) X##Y
|
||||||
#define TEST_CONCAT(X, Y) TEST_CONCAT1(X, Y)
|
#define TEST_CONCAT(X, Y) TEST_CONCAT1(X, Y)
|
||||||
|
|
||||||
@@ -177,4 +182,9 @@ struct is_same<T, T> { enum {value = 1}; };
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(__GNUC__)
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // SUPPORT_TEST_MACROS_HPP
|
#endif // SUPPORT_TEST_MACROS_HPP
|
||||||
|
|||||||
Reference in New Issue
Block a user