diff --git a/thrust/testing/unittest/runtime_static_assert.h b/thrust/testing/unittest/runtime_static_assert.h deleted file mode 100644 index 73cb1d235b2..00000000000 --- a/thrust/testing/unittest/runtime_static_assert.h +++ /dev/null @@ -1,115 +0,0 @@ -#pragma once - -#include - -#include -#undef THRUST_STATIC_ASSERT -#undef THRUST_STATIC_ASSERT_MSG - -#define THRUST_STATIC_ASSERT(B) unittest::assert_static((B), __FILE__, __LINE__); -#define THRUST_STATIC_ASSERT_MSG(B, msg) unittest::assert_static((B), __FILE__, __LINE__); - -namespace unittest -{ -_CCCL_HOST_DEVICE void assert_static(bool condition, const char* filename, int lineno); -} - -#include -#include - -#include - -#if THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_CUDA - -# define ASSERT_STATIC_ASSERT(X) \ - { \ - bool triggered = false; \ - using ex_t = unittest::static_assert_exception; \ - thrust::device_ptr device_ptr = thrust::device_new(); \ - ex_t* raw_ptr = thrust::raw_pointer_cast(device_ptr); \ - ::cudaMemcpyToSymbol(unittest::detail::device_exception, &raw_ptr, sizeof(ex_t*)); \ - try \ - { \ - X; \ - } \ - catch (ex_t) \ - { \ - triggered = true; \ - } \ - if (!triggered) \ - { \ - triggered = static_cast(*device_ptr).triggered; \ - } \ - thrust::device_free(device_ptr); \ - raw_ptr = nullptr; \ - ::cudaMemcpyToSymbol(unittest::detail::device_exception, &raw_ptr, sizeof(ex_t*)); \ - if (!triggered) \ - { \ - unittest::UnitTestFailure f; \ - f << "[" << __FILE__ << ":" << __LINE__ << "] did not trigger a THRUST_STATIC_ASSERT"; \ - throw f; \ - } \ - } - -#else - -# define ASSERT_STATIC_ASSERT(X) \ - { \ - bool triggered = false; \ - using ex_t = unittest::static_assert_exception; \ - try \ - { \ - X; \ - } \ - catch (ex_t) \ - { \ - triggered = true; \ - } \ - if (!triggered) \ - { \ - unittest::UnitTestFailure f; \ - f << "[" << __FILE__ << ":" << __LINE__ << "] did not trigger a THRUST_STATIC_ASSERT"; \ - throw f; \ - } \ - } - -#endif - -namespace unittest -{ -class static_assert_exception -{ -public: - _CCCL_HOST_DEVICE static_assert_exception() - : triggered(false) - {} - - _CCCL_HOST_DEVICE static_assert_exception(const char* filename, int lineno) - : triggered(true) - , filename(filename) - , lineno(lineno) - {} - - bool triggered; - const char* filename; - int lineno; -}; - -namespace detail -{ -#if _CCCL_COMPILER(GCC) || _CCCL_COMPILER(CLANG) -__attribute__((used)) -#endif -_CCCL_DEVICE static static_assert_exception* device_exception = nullptr; -} // namespace detail - -_CCCL_HOST_DEVICE void assert_static(bool condition, const char* filename, int lineno) -{ - if (!condition) - { - static_assert_exception ex(filename, lineno); - - NV_IF_TARGET(NV_IS_DEVICE, (*detail::device_exception = ex;), (throw ex;)); - } -} -} // namespace unittest diff --git a/thrust/testing/unittest_static_assert.cmake b/thrust/testing/unittest_static_assert.cmake deleted file mode 100644 index 9f65a656dd2..00000000000 --- a/thrust/testing/unittest_static_assert.cmake +++ /dev/null @@ -1,10 +0,0 @@ -# Disable unreachable code warnings. -# This test unconditionally throws in some places, the compiler will detect that -# control flow will never reach some instructions. This is intentional. -target_link_libraries(${test_target} PRIVATE cccl.silence_unreachable_code_warnings) - -# The machinery behind this test is not compatible with NVC++. -# See https://github.com/NVIDIA/thrust/issues/1397 -if ("NVHPC" STREQUAL "${CMAKE_CUDA_COMPILER_ID}") - set_tests_properties(${test_target} PROPERTIES DISABLED True) -endif() diff --git a/thrust/testing/unittest_static_assert.cu b/thrust/testing/unittest_static_assert.cu deleted file mode 100644 index 6c45a80bbfc..00000000000 --- a/thrust/testing/unittest_static_assert.cu +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include - -// The runtime_static_assert header needs to come first as we are overwriting thrusts internal static assert -#include - -template -struct dependent_false -{ - enum - { - value = false - }; -}; - -template -struct static_assertion -{ - _CCCL_HOST_DEVICE T operator()() const - { - THRUST_STATIC_ASSERT(dependent_false::value); - return 0; - } -}; - -template -void TestStaticAssertAssert() -{ - using value_type = typename V::value_type; - V test(10); - ASSERT_STATIC_ASSERT(thrust::generate(test.begin(), test.end(), static_assertion())); -} -DECLARE_VECTOR_UNITTEST(TestStaticAssertAssert);