@@ -50,18 +50,16 @@ constexpr bool msvc_is_lock_free_macro_value() {
50
50
# error "Unknown compiler"
51
51
#endif
52
52
53
+ #ifdef TEST_COMPILER_CLANG
54
+ # pragma clang diagnostic push
55
+ # pragma clang diagnostic ignored "-Wc++11-extensions"
56
+ #endif
53
57
// The entire LockFreeStatus/LockFreeStatusEnum/LockFreeStatusType exists entirely to work around the support
54
58
// for C++03, which many of our atomic tests run under. This is a bit of a hack, but it's the best we can do.
55
59
//
56
60
// We could limit the testing involving these things to C++11 or greater? But test coverage in C++03 seems important too.
57
- #if TEST_STD_VER < 11
58
- struct LockFreeStatusEnum {
59
- enum LockFreeStatus { unknown = -1 , never = 0 , sometimes = 1 , always = 2 };
60
- };
61
- typedef LockFreeStatusEnum::LockFreeStatus LockFreeStatus;
62
- #else
61
+
63
62
enum class LockFreeStatus : int { unknown = -1 , never = 0 , sometimes = 1 , always = 2 };
64
- #endif
65
63
#define COMPARE_TYPES (T1, T2 ) (sizeof (T1) == sizeof (T2) && TEST_ALIGNOF(T1) >= TEST_ALIGNOF(T2))
66
64
67
65
template <class T >
@@ -79,9 +77,11 @@ struct LockFreeStatusInfo {
79
77
? TEST_ATOMIC_LLONG_LOCK_FREE
80
78
: (COMPARE_TYPES(T, void *) ? TEST_ATOMIC_POINTER_LOCK_FREE : -1 ))))));
81
79
82
- static const bool status_known = value != LockFreeStatus::unknown;
80
+ static const bool status_known = LockFreeStatusInfo:: value != LockFreeStatus::unknown;
83
81
};
84
82
83
+ // IDK why this blows up in C++03, but it does. So we'll just disable it.
84
+ #if TEST_STD_VER >= 11
85
85
static_assert (LockFreeStatusInfo<char >::status_known, " " );
86
86
static_assert (LockFreeStatusInfo<short >::status_known, " " );
87
87
static_assert (LockFreeStatusInfo<int >::status_known, " " );
@@ -94,6 +94,7 @@ static_assert(LockFreeStatusInfo<char>::value == LockFreeStatus::always, "");
94
94
static_assert (LockFreeStatusInfo<short >::value == LockFreeStatus::always, " " );
95
95
static_assert (LockFreeStatusInfo<int >::value == LockFreeStatus::always,
96
96
" " ); // This one may not always be lock free, but we'll let the CI decide.
97
+ #endif
97
98
98
99
// These macros are somewhat suprising to use, since they take the values 0, 1, or 2.
99
100
// To make the tests clearer, get rid of them in preference of AtomicInfo.
@@ -104,6 +105,10 @@ static_assert(LockFreeStatusInfo<int>::value == LockFreeStatus::always,
104
105
#undef TEST_ATOMIC_LLONG_LOCK_FREE
105
106
#undef TEST_ATOMIC_POINTER_LOCK_FREE
106
107
108
+ #ifdef TEST_COMPILER_CLANG
109
+ # pragma clang diagnostic pop
110
+ #endif
111
+
107
112
struct UserAtomicType {
108
113
int i;
109
114
0 commit comments