1 // -*- C++ -*- 2 //===---------------------------- test_macros.h ---------------------------===// 3 // 4 // The LLVM Compiler Infrastructure 5 // 6 // This file is dual licensed under the MIT and the University of Illinois Open 7 // Source Licenses. See LICENSE.TXT for details. 8 // 9 //===----------------------------------------------------------------------===// 10 11 #ifndef SUPPORT_TEST_MACROS_HPP 12 #define SUPPORT_TEST_MACROS_HPP 13 14 #define TEST_CONCAT1(X, Y) X##Y 15 #define TEST_CONCAT(X, Y) TEST_CONCAT1(X, Y) 16 17 #ifdef __has_feature 18 #define TEST_HAS_FEATURE(X) __has_feature(X) 19 #else 20 #define TEST_HAS_FEATURE(X) 0 21 #endif 22 23 #ifdef __has_extension 24 #define TEST_HAS_EXTENSION(X) __has_extension(X) 25 #else 26 #define TEST_HAS_EXTENSION(X) 0 27 #endif 28 29 /* Make a nice name for the standard version */ 30 #if __cplusplus <= 199711L 31 # define TEST_STD_VER 3 32 #elif __cplusplus <= 201103L 33 # define TEST_STD_VER 11 34 #elif __cplusplus <= 201402L 35 # define TEST_STD_VER 14 36 #else 37 # define TEST_STD_VER 99 // greater than current standard 38 #endif 39 40 /* Features that were introduced in C++11 */ 41 #if TEST_STD_VER >= 11 42 #define TEST_HAS_RVALUE_REFERENCES 43 #define TEST_HAS_VARIADIC_TEMPLATES 44 #define TEST_HAS_INITIALIZER_LISTS 45 #define TEST_HAS_BASIC_CONSTEXPR 46 #endif 47 48 /* Features that were introduced in C++14 */ 49 #if TEST_STD_VER >= 14 50 #define TEST_HAS_EXTENDED_CONSTEXPR 51 #define TEST_HAS_VARIABLE_TEMPLATES 52 #endif 53 54 /* Features that were introduced after C++14 */ 55 #if TEST_STD_VER > 14 56 #endif 57 58 #if TEST_HAS_EXTENSION(cxx_decltype) || TEST_STD_VER >= 11 59 #define TEST_DECLTYPE(T) decltype(T) 60 #else 61 #define TEST_DECLTYPE(T) __typeof__(T) 62 #endif 63 64 #if TEST_STD_VER >= 11 65 #define TEST_CONSTEXPR constexpr 66 #define TEST_NOEXCEPT noexcept 67 #else 68 #define TEST_CONSTEXPR 69 #define TEST_NOEXCEPT 70 #endif 71 72 #if TEST_HAS_EXTENSION(cxx_static_assert) || TEST_STD_VER >= 11 73 # define TEST_STATIC_ASSERT(Expr, Msg) static_assert(Expr, Msg) 74 #else 75 # define TEST_STATIC_ASSERT(Expr, Msg) \ 76 typedef ::test_detail::static_assert_check<sizeof( \ 77 ::test_detail::static_assert_incomplete_test<(Expr)>)> \ 78 TEST_CONCAT(test_assert, __LINE__) 79 # 80 #endif 81 82 namespace test_detail { 83 84 template <bool> struct static_assert_incomplete_test; 85 template <> struct static_assert_incomplete_test<true> {}; 86 template <unsigned> struct static_assert_check {}; 87 88 } // end namespace test_detail 89 90 91 #if !TEST_HAS_FEATURE(cxx_rtti) && !defined(__cxx_rtti) 92 #define TEST_HAS_NO_RTTI 93 #endif 94 95 #if !TEST_HAS_FEATURE(cxx_exceptions) && !defined(__cxx_exceptions) 96 #define TEST_HAS_NO_EXCEPTIONS 97 #endif 98 99 #endif // SUPPORT_TEST_MACROS_HPP 100