Skip to content

Commit

Permalink
Fix tests failing with ICC due to noexcept bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
miscco committed Nov 29, 2023
1 parent 68b760e commit 0c0711b
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 25 deletions.
6 changes: 5 additions & 1 deletion libcudacxx/libcxx/test/support/test_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@
#define TEST_HAS_BUILTIN_IDENTIFIER(X) 0
#endif

#if defined(__NVCOMPILER)
#if defined(__INTEL_LLVM_COMPILER)
# define TEST_COMPILER_ICC_LLVM
#elif defined(__INTEL_COMPILER)
# define TEST_COMPILER_ICC
#elif defined(__NVCOMPILER)
# define TEST_COMPILER_NVHPC
#elif defined(__clang__)
# define TEST_COMPILER_CLANG
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void test()
assert(atomic_flag_test_and_set_explicit(&f, cuda::std::memory_order_relaxed) == 0);
assert(f.test_and_set() == 1);
}
#ifndef __INTEL_COMPILER
#ifndef TEST_COMPILER_ICC
{
Selector<cuda::std::atomic_flag, default_initializer> sel;
cuda::std::atomic_flag & f = *sel.construct();
Expand Down Expand Up @@ -78,7 +78,7 @@ void test()
assert(atomic_flag_test_and_set_explicit(&f, cuda::std::memory_order_relaxed) == 0);
assert(f.test_and_set() == 1);
}
#ifndef __INTEL_COMPILER
#ifndef TEST_COMPILER_ICC
{
Selector<volatile cuda::std::atomic_flag, default_initializer> sel;
volatile cuda::std::atomic_flag & f = *sel.construct();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void test()
assert(f.test_and_set(cuda::std::memory_order_relaxed) == 0);
assert(f.test_and_set(cuda::std::memory_order_relaxed) == 1);
}
#ifndef __INTEL_COMPILER
#ifndef TEST_COMPILER_ICC
{
Selector<cuda::std::atomic_flag, default_initializer> sel;
cuda::std::atomic_flag & f = *sel.construct();
Expand Down Expand Up @@ -91,7 +91,7 @@ void test()
assert(f.test_and_set(cuda::std::memory_order_relaxed) == 0);
assert(f.test_and_set(cuda::std::memory_order_relaxed) == 1);
}
#ifndef __INTEL_COMPILER
#ifndef TEST_COMPILER_ICC
{
Selector<volatile cuda::std::atomic_flag, default_initializer> sel;
volatile cuda::std::atomic_flag & f = *sel.construct();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ int main(int, char**)
{
using Ref = cuda::std::reference_wrapper<int>;
ASSERT_NOEXCEPT(Ref(nothrow_convertible<true>()));
#if !defined(TEST_COMPILER_NVHPC) && !defined(__INTEL_COMPILER) && !defined(__INTEL_LLVM_COMPILER)
#if !defined(TEST_COMPILER_NVHPC) && !defined(TEST_COMPILER_ICC) && !defined(TEST_COMPILER_ICC_LLVM)
ASSERT_NOT_NOEXCEPT(Ref(nothrow_convertible<false>()));
#endif // !defined(TEST_COMPILER_NVHPC) && !defined(__INTEL_COMPILER) && !defined(__INTEL_LLVM_COMPILER)
#endif // !defined(TEST_COMPILER_NVHPC) && !defined(TEST_COMPILER_ICC) && !defined(TEST_COMPILER_ICC_LLVM)
}
{
meow(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ __host__ __device__ TEST_CONSTEXPR_CXX20 bool test()
{
{
A1 a{};
#if !defined(TEST_COMPILER_NVHPC) && !defined(__INTEL_COMPILER) && !defined(__INTEL_LLVM_COMPILER)
#if !defined(TEST_COMPILER_NVHPC) && !defined(TEST_COMPILER_ICC) && !defined(TEST_COMPILER_ICC_LLVM)
ASSERT_NOT_NOEXCEPT(implicitly_convert(a));
#endif // TEST_COMPILER_NVHPC
cuda::std::reference_wrapper<B> b1 = a;
assert(&b1.get() == &a.b_);
#if !defined(TEST_COMPILER_NVHPC) && !defined(__INTEL_COMPILER) && !defined(__INTEL_LLVM_COMPILER)
#if !defined(TEST_COMPILER_NVHPC) && !defined(TEST_COMPILER_ICC) && !defined(TEST_COMPILER_ICC_LLVM)
ASSERT_NOT_NOEXCEPT(b1 = a);
#endif // TEST_COMPILER_NVHPC
b1 = a;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ int main(int, char**)
test_is_not_nothrow_assignable<int, int> ();

test_is_not_nothrow_assignable<A, B> ();
#ifndef TEST_COMPILER_NVHPC
#if !defined(TEST_COMPILER_NVHPC) && !defined(TEST_COMPILER_ICC)
test_is_not_nothrow_assignable<B, A> ();
test_is_not_nothrow_assignable<C, C&> ();
#endif // TEST_COMPILER_NVHPC
#endif // !TEST_COMPILER_NVHPC && !TEST_COMPILER_ICC

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ int main(int, char**)

test_has_not_nothrow_assign<const int>();
test_has_not_nothrow_assign<void>();
#ifndef TEST_COMPILER_NVHPC
#if !defined(TEST_COMPILER_NVHPC) && !defined(TEST_COMPILER_ICC)
test_has_not_nothrow_assign<A>();
#endif // TEST_COMPILER_NVHPC
#endif // !TEST_COMPILER_NVHPC && !TEST_COMPILER_ICC

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ struct A
int main(int, char**)
{
test_has_not_nothrow_copy_constructor<void>();
#ifndef TEST_COMPILER_NVHPC
#if !defined(TEST_COMPILER_NVHPC) && !defined(TEST_COMPILER_ICC)
test_has_not_nothrow_copy_constructor<A>();
#endif // TEST_COMPILER_NVHPC
#endif // !TEST_COMPILER_NVHPC && !TEST_COMPILER_ICC

test_is_nothrow_copy_constructible<int&>();
test_is_nothrow_copy_constructible<Union>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ int main(int, char**)
{
test_has_not_nothrow_default_constructor<void>();
test_has_not_nothrow_default_constructor<int&>();
#ifndef TEST_COMPILER_NVHPC
#if !defined(TEST_COMPILER_NVHPC) && !defined(TEST_COMPILER_ICC)
test_has_not_nothrow_default_constructor<A>();
#if !defined(__INTEL_COMPILER) && !defined(TEST_COMPILER_MSVC_2017)
#if !defined(TEST_COMPILER_MSVC_2017)
test_has_not_nothrow_default_constructor<DThrows>(); // This is LWG2116
#endif
#endif // TEST_COMPILER_NVHPC
#endif // !TEST_COMPILER_MSVC_2017
#endif // !TEST_COMPILER_NVHPC && !TEST_COMPILER_ICC

test_is_nothrow_default_constructible<Union>();
test_is_nothrow_default_constructible<Empty>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ int main(int, char**)
test_has_nothrow_assign<bit_zero>();

test_has_not_nothrow_assign<void>();
#ifndef TEST_COMPILER_NVHPC
#if !defined(TEST_COMPILER_NVHPC) && !defined(TEST_COMPILER_ICC)
test_has_not_nothrow_assign<A>();
#endif // TEST_COMPILER_NVHPC
#endif // !TEST_COMPILER_NVHPC && !TEST_COMPILER_ICC

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ template <class T>
__host__ __device__
void test_has_not_nothrow_move_constructor()
{
#if !defined(TEST_COMPILER_NVHPC) && !defined(__INTEL_COMPILER) && !defined(__INTEL_LLVM_COMPILER)
#if !defined(TEST_COMPILER_NVHPC) && !defined(TEST_COMPILER_ICC) && !defined(TEST_COMPILER_ICC_LLVM)
static_assert(!cuda::std::is_nothrow_move_constructible<T>::value, "");
static_assert(!cuda::std::is_nothrow_move_constructible<const T>::value, "");
#endif // !defined(TEST_COMPILER_NVHPC) && !defined(__INTEL_COMPILER) && !defined(__INTEL_LLVM_COMPILER)
#endif // !defined(TEST_COMPILER_NVHPC) && !defined(TEST_COMPILER_ICC) && !defined(TEST_COMPILER_ICC_LLVM)
static_assert(!cuda::std::is_nothrow_move_constructible<volatile T>::value, "");
static_assert(!cuda::std::is_nothrow_move_constructible<const volatile T>::value, "");
#if TEST_STD_VER > 11
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ int main(int, char**)
static_assert(noexcept(cuda::std::tuple<NoExceptDefault>()), "");
static_assert(noexcept(cuda::std::tuple<NoExceptDefault, NoExceptDefault>()), "");

#ifndef TEST_COMPILER_NVHPC
#if !defined(TEST_COMPILER_NVHPC) && !defined(TEST_COMPILER_ICC)
static_assert(!noexcept(cuda::std::tuple<ThrowingDefault, NoExceptDefault>()), "");
static_assert(!noexcept(cuda::std::tuple<NoExceptDefault, ThrowingDefault>()), "");
static_assert(!noexcept(cuda::std::tuple<ThrowingDefault, ThrowingDefault>()), "");
#endif // TEST_COMPILER_NVHPC
#endif // !TEST_COMPILER_NVHPC && !TEST_COMPILER_ICC
}
{
constexpr cuda::std::tuple<> t;
Expand Down

0 comments on commit 0c0711b

Please sign in to comment.