summaryrefslogtreecommitdiff
path: root/test/support/test_macros.h
diff options
context:
space:
mode:
Diffstat (limited to 'test/support/test_macros.h')
-rw-r--r--test/support/test_macros.h34
1 files changed, 27 insertions, 7 deletions
diff --git a/test/support/test_macros.h b/test/support/test_macros.h
index 257875a35ed2..dbbfd53094e6 100644
--- a/test/support/test_macros.h
+++ b/test/support/test_macros.h
@@ -27,10 +27,8 @@
#define TEST_HAS_FEATURE(X) 0
#endif
-#ifdef __has_include
-#define TEST_HAS_INCLUDE(X) __has_include(X)
-#else
-#define TEST_HAS_INCLUDE(X) 0
+#ifndef __has_include
+#define __has_include(...) 0
#endif
#ifdef __has_extension
@@ -90,7 +88,7 @@
#endif
// Attempt to deduce GCC version
-#if defined(_LIBCPP_VERSION) && TEST_HAS_INCLUDE(<features.h>)
+#if defined(_LIBCPP_VERSION) && __has_include(<features.h>)
#include <features.h>
#define TEST_HAS_GLIBC
#define TEST_GLIBC_PREREQ(major, minor) __GLIBC_PREREQ(major, minor)
@@ -157,12 +155,23 @@
#define TEST_NORETURN [[noreturn]]
#endif
+#if defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) || \
+ (!(TEST_STD_VER > 14 || \
+ (defined(__cpp_aligned_new) && __cpp_aligned_new >= 201606L)))
+#define TEST_HAS_NO_ALIGNED_ALLOCATION
+#endif
+
#if defined(_LIBCPP_SAFE_STATIC)
#define TEST_SAFE_STATIC _LIBCPP_SAFE_STATIC
#else
#define TEST_SAFE_STATIC
#endif
+// FIXME: Fix this feature check when either (A) a compiler provides a complete
+// implementation, or (b) a feature check macro is specified
+#define TEST_HAS_NO_SPACESHIP_OPERATOR
+
+
#if TEST_STD_VER < 11
#define ASSERT_NOEXCEPT(...)
#define ASSERT_NOT_NOEXCEPT(...)
@@ -215,8 +224,18 @@ struct is_same<T, T> { enum {value = 1}; };
#if defined(__GNUC__) || defined(__clang__)
template <class Tp>
-inline void DoNotOptimize(Tp const& value) {
- asm volatile("" : : "g"(value) : "memory");
+inline
+void DoNotOptimize(Tp const& value) {
+ asm volatile("" : : "r,m"(value) : "memory");
+}
+
+template <class Tp>
+inline void DoNotOptimize(Tp& value) {
+#if defined(__clang__)
+ asm volatile("" : "+r,m"(value) : : "memory");
+#else
+ asm volatile("" : "+m,r"(value) : : "memory");
+#endif
}
#else
#include <intrin.h>
@@ -228,6 +247,7 @@ inline void DoNotOptimize(Tp const& value) {
}
#endif
+
#if defined(__GNUC__)
#pragma GCC diagnostic pop
#endif