Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Commit

Permalink
Try to fix nvrtc with respect to spaceship operator
Browse files Browse the repository at this point in the history
  • Loading branch information
miscco committed Jan 27, 2023
1 parent fa29dd2 commit 6c443bf
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,12 @@ namespace types_fit_for_purpose {
#if TEST_STD_VER > 17
static_assert(equality_comparable<cxx20_member_eq>, "");
static_assert(equality_comparable<cxx20_friend_eq>, "");
#ifndef TEST_HAS_NO_SPACESHIP_OPERATOR
static_assert(equality_comparable<member_three_way_comparable>, "");
#ifndef __NVCC__ // nvbug3908399
static_assert(equality_comparable<friend_three_way_comparable>, "");
#endif // !__NVCC_
#endif // TEST_HAS_NO_SPACESHIP_OPERATOR
static_assert(equality_comparable<explicit_operators>, "");
static_assert(equality_comparable<different_return_types>, "");
static_assert(equality_comparable<one_member_one_friend>, "");
Expand All @@ -117,14 +121,18 @@ static_assert(
!equality_comparable<cxx20_member_eq_operator_with_deleted_ne>, "");
static_assert(
!equality_comparable<cxx20_friend_eq_operator_with_deleted_ne>, "");
#ifndef TEST_HAS_NO_SPACESHIP_OPERATOR
static_assert(
!equality_comparable<member_three_way_comparable_with_deleted_eq>, "");
static_assert(
!equality_comparable<member_three_way_comparable_with_deleted_ne>, "");
static_assert(
!equality_comparable<friend_three_way_comparable_with_deleted_eq>, "");
#ifndef __NVCC__ // nvbug3908399
static_assert(
!equality_comparable<friend_three_way_comparable_with_deleted_ne>, "");
#endif // !__NVCC__
#endif // TEST_HAS_NO_SPACESHIP_OPERATOR

static_assert(!equality_comparable<eq_returns_explicit_bool>, "");
static_assert(!equality_comparable<ne_returns_explicit_bool>, "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,7 @@ static_assert(
static_assert(
!check_equality_comparable_with<cxx20_member_eq, cxx20_friend_eq>(), "");

#ifndef TEST_HAS_NO_SPACESHIP_OPERATOR
static_assert(check_equality_comparable_with<member_three_way_comparable,
member_three_way_comparable>(), "");
#ifndef __NVCC__ // nvbug3908399
Expand All @@ -1063,6 +1064,7 @@ static_assert(check_equality_comparable_with<friend_three_way_comparable,
static_assert(!check_equality_comparable_with<member_three_way_comparable,
friend_three_way_comparable>(), "");
#endif // !__NVCC__
#endif // TEST_HAS_NO_SPACESHIP_OPERATOR
#endif // TEST_STD_VER > 17

static_assert(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,12 @@ static_assert(models_totally_ordered<cuda::std::array<int, 10> >(), "");

namespace types_fit_for_purpose {
#if TEST_STD_VER > 17
#ifndef TEST_HAS_NO_SPACESHIP_OPERATOR
static_assert(models_totally_ordered<member_three_way_comparable>(), "");
#ifndef __NVCC__ // nvbug3908399
static_assert(models_totally_ordered<friend_three_way_comparable>(), "");
#endif // !__NVCC__
#endif // TEST_HAS_NO_SPACESHIP_OPERATOR

static_assert(models_totally_ordered<explicit_operators>(), "");
static_assert(models_totally_ordered<different_return_types>(), "");
Expand Down Expand Up @@ -147,6 +149,7 @@ static_assert(!totally_ordered<wrong_return_type>, "");
#if TEST_STD_VER > 17
static_assert(!totally_ordered<cxx20_member_eq_operator_with_deleted_ne>, "");
static_assert(!totally_ordered<cxx20_friend_eq_operator_with_deleted_ne>, "");
#ifndef TEST_HAS_NO_SPACESHIP_OPERATOR
static_assert(
!totally_ordered<member_three_way_comparable_with_deleted_eq>, "");
static_assert(
Expand All @@ -157,6 +160,7 @@ static_assert(
static_assert(
!totally_ordered<friend_three_way_comparable_with_deleted_ne>, "");
#endif // !__NVCC__
#endif // TEST_HAS_NO_SPACESHIP_OPERATOR

static_assert(!totally_ordered<eq_returns_explicit_bool>, "");
static_assert(!totally_ordered<ne_returns_explicit_bool>, "");
Expand All @@ -167,11 +171,13 @@ static_assert(!totally_ordered<ge_returns_explicit_bool>, "");
static_assert(totally_ordered<returns_true_type>, "");
static_assert(totally_ordered<returns_int_ptr>, "");

#ifndef TEST_HAS_NO_SPACESHIP_OPERATOR
#ifndef TEST_HAS_NO_SPACESHIP_OPERATOR
static_assert(totally_ordered<partial_ordering_totally_ordered_with>, "");
static_assert(totally_ordered<weak_ordering_totally_ordered_with>, "");
static_assert(totally_ordered<strong_ordering_totally_ordered_with>, "");
#endif // TEST_HAS_NO_SPACESHIP_OPERATOR
#endif // TEST_HAS_NO_SPACESHIP_OPERATOR
#endif // TEST_STD_VER > 17
} // namespace types_fit_for_purpose

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,7 @@ static_assert(!check_totally_ordered_with<cxx20_member_eq, cxx20_member_eq>(), "
static_assert(!check_totally_ordered_with<cxx20_friend_eq, cxx20_friend_eq>(), "");
static_assert(!check_totally_ordered_with<cxx20_member_eq, cxx20_friend_eq>(), "");

#ifndef TEST_HAS_NO_SPACESHIP_OPERATOR
static_assert(check_totally_ordered_with<member_three_way_comparable,
member_three_way_comparable>(), "");
#ifndef __NVCC__ // nvbug3908399
Expand All @@ -1029,6 +1030,7 @@ static_assert(check_totally_ordered_with<friend_three_way_comparable,
static_assert(!check_totally_ordered_with<member_three_way_comparable,
friend_three_way_comparable>(), "");
#endif // !__NVCC__
#endif // TEST_HAS_NO_SPACESHIP_OPERATOR
#endif // TEST_STD_VER > 17

static_assert(
Expand All @@ -1053,6 +1055,7 @@ static_assert(
cuda::std::common_reference_with<one_way_ne const&, explicit_operators const&> &&
!check_totally_ordered_with<one_way_ne, explicit_operators>(), "");

#ifndef TEST_HAS_NO_SPACESHIP_OPERATOR
#ifndef TEST_HAS_NO_SPACESHIP_OPERATOR
static_assert(
check_totally_ordered_with<totally_ordered_with_others,
Expand Down Expand Up @@ -1113,6 +1116,7 @@ static_assert(
no_ge_not_totally_ordered_with> &&
!check_totally_ordered_with<totally_ordered_with_others,
no_ge_not_totally_ordered_with>(), "");
#endif // TEST_HAS_NO_SPACESHIP_OPERATOR
#endif // TEST_STD_VER > 17
} // namespace types_fit_for_purpose

Expand Down
12 changes: 11 additions & 1 deletion .upstream-tests/test/support/compare_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
#include <cuda/std/concepts>
#include <cuda/std/type_traits>

#ifndef TEST_HAS_NO_SPACESHIP_OPERATOR
#include <compare>
#endif // TEST_HAS_NO_SPACESHIP_OPERATOR

// `noexcept` specifiers deliberately imperfect since not all programmers bother to put the
// specifiers on their overloads.

Expand All @@ -27,6 +31,7 @@ struct cxx20_friend_eq {
__host__ __device__ friend bool operator==(cxx20_friend_eq const&, cxx20_friend_eq const&) = default;
};

#ifndef TEST_HAS_NO_SPACESHIP_OPERATOR
struct member_three_way_comparable {
auto operator<=>(member_three_way_comparable const&) const = default;
};
Expand All @@ -36,6 +41,7 @@ struct friend_three_way_comparable {
__host__ __device__ friend auto operator<=>(friend_three_way_comparable const&, friend_three_way_comparable const&) = default;
};
#endif // !__NVCC__
#endif // TEST_HAS_NO_SPACESHIP_OPERATOR
#endif // TEST_STD_VER > 17

struct explicit_operators {
Expand Down Expand Up @@ -216,6 +222,7 @@ struct cxx20_friend_eq_operator_with_deleted_ne {
cxx20_friend_eq_operator_with_deleted_ne const&) = delete;
};

#ifndef TEST_HAS_NO_SPACESHIP_OPERATOR
struct member_three_way_comparable_with_deleted_eq {
auto operator<=>(member_three_way_comparable_with_deleted_eq const&) const = default;
__host__ __device__ bool operator==(member_three_way_comparable_with_deleted_eq const&) const = delete;
Expand All @@ -241,6 +248,7 @@ struct friend_three_way_comparable_with_deleted_ne {
friend_three_way_comparable_with_deleted_ne const&) = delete;
};
#endif
#endif // TEST_HAS_NO_SPACESHIP_OPERATOR

struct one_way_eq {
bool operator==(one_way_eq const&) const = default;
Expand All @@ -265,6 +273,7 @@ struct explicit_bool {
};

#if TEST_STD_VER > 17
#ifndef TEST_HAS_NO_SPACESHIP_OPERATOR
struct totally_ordered_with_others {
auto operator<=>(totally_ordered_with_others const&) const = default;
};
Expand Down Expand Up @@ -330,7 +339,8 @@ struct strong_ordering_totally_ordered_with {

__host__ __device__ operator totally_ordered_with_others() const;
};
#endif
#endif // TEST_HAS_NO_SPACESHIP_OPERATOR
#endif // TEST_STD_VER > 17

struct eq_returns_explicit_bool {
__host__ __device__ friend explicit_bool operator==(eq_returns_explicit_bool, eq_returns_explicit_bool);
Expand Down
2 changes: 1 addition & 1 deletion .upstream-tests/test/support/test_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@

// FIXME: Fix this feature check when either (A) a compiler provides a complete
// implementation, or (b) a feature check macro is specified
#if defined(TEST_COMPILER_CLANG) || !defined(TEST_COMPILER_C1XX) || _MSC_VER < 1920 || _MSVC_LANG <= 201703L
#if !defined(__cpp_lib_three_way_comparison)
#define TEST_HAS_NO_SPACESHIP_OPERATOR
#endif

Expand Down

0 comments on commit 6c443bf

Please sign in to comment.