Skip to content

Commit

Permalink
Make optional compile with old clang and nvcc
Browse files Browse the repository at this point in the history
  • Loading branch information
miscco committed Jun 27, 2023
1 parent 8c0fff9 commit b92504b
Show file tree
Hide file tree
Showing 49 changed files with 310 additions and 155 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ constexpr bool test() {
typedef optional<T> O;

constexpr T val(2);
constexpr O o1; // disengaged
constexpr O o2{1}; // engaged
constexpr O o3{val}; // engaged
O o1; // disengaged
O o2{1}; // engaged
O o3{val}; // engaged

assert(!(o1 == T(1)));
assert((o2 == T(1)));
Expand All @@ -57,13 +57,13 @@ constexpr bool test() {
}
{
using O = optional<int>;
constexpr O o1(42);
O o1(42);
assert(o1 == 42l);
assert(!(101l == o1));
}
{
using O = optional<const int>;
constexpr O o1(42);
O o1(42);
assert(o1 == 42);
assert(!(101 == o1));
}
Expand All @@ -74,7 +74,9 @@ constexpr bool test() {
int main(int, char**) {
test();
#if TEST_STD_VER >= 17
#if !(defined(TEST_COMPILER_NVCC) && _LIBCUDACXX_CUDACC_VER < 1103000 && defined(TEST_COMPILER_CLANG))
static_assert(test());
#endif // !(defined(TEST_COMPILER_NVCC) && _LIBCUDACXX_CUDACC_VER < 1103000 && defined(TEST_COMPILER_CLANG))
#endif

return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ constexpr bool test() {
typedef optional<T> O;

constexpr T val(2);
constexpr O o1; // disengaged
constexpr O o2{1}; // engaged
constexpr O o3{val}; // engaged
O o1; // disengaged
O o2{1}; // engaged
O o3{val}; // engaged

assert(!(o1 > T(1)));
assert(!(o2 > T(1))); // equal
Expand All @@ -57,13 +57,13 @@ constexpr bool test() {
}
{
using O = optional<int>;
constexpr O o1(42);
O o1(42);
assert(o1 > 11l);
assert(!(42l > o1));
}
{
using O = optional<const int>;
constexpr O o1(42);
O o1(42);
assert(o1 > 11);
assert(!(42 > o1));
}
Expand All @@ -74,7 +74,9 @@ constexpr bool test() {
int main(int, char**) {
test();
#if TEST_STD_VER >= 17
#if !(defined(TEST_COMPILER_NVCC) && _LIBCUDACXX_CUDACC_VER < 1103000 && defined(TEST_COMPILER_CLANG))
static_assert(test());
#endif // !(defined(TEST_COMPILER_NVCC) && _LIBCUDACXX_CUDACC_VER < 1103000 && defined(TEST_COMPILER_CLANG))
#endif

return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ constexpr bool test() {
typedef optional<T> O;

constexpr T val(2);
constexpr O o1; // disengaged
constexpr O o2{1}; // engaged
constexpr O o3{val}; // engaged
O o1; // disengaged
O o2{1}; // engaged
O o3{val}; // engaged

assert(!(o1 >= T(1)));
assert((o2 >= T(1))); // equal
Expand All @@ -59,13 +59,13 @@ constexpr bool test() {
}
{
using O = optional<int>;
constexpr O o1(42);
O o1(42);
assert(o1 >= 42l);
assert(!(11l >= o1));
}
{
using O = optional<const int>;
constexpr O o1(42);
O o1(42);
assert(o1 >= 42);
assert(!(11 >= o1));
}
Expand All @@ -76,7 +76,9 @@ constexpr bool test() {
int main(int, char**) {
test();
#if TEST_STD_VER >= 17
#if !(defined(TEST_COMPILER_NVCC) && _LIBCUDACXX_CUDACC_VER < 1103000 && defined(TEST_COMPILER_CLANG))
static_assert(test());
#endif // !(defined(TEST_COMPILER_NVCC) && _LIBCUDACXX_CUDACC_VER < 1103000 && defined(TEST_COMPILER_CLANG))
#endif

return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ constexpr bool test() {
typedef optional<T> O;

constexpr T val(2);
constexpr O o1; // disengaged
constexpr O o2{1}; // engaged
constexpr O o3{val}; // engaged
O o1; // disengaged
O o2{1}; // engaged
O o3{val}; // engaged

assert((o1 <= T(1)));
assert((o2 <= T(1))); // equal
Expand All @@ -59,13 +59,13 @@ constexpr bool test() {
}
{
using O = optional<int>;
constexpr O o1(42);
O o1(42);
assert(o1 <= 42l);
assert(!(101l <= o1));
}
{
using O = optional<const int>;
constexpr O o1(42);
O o1(42);
assert(o1 <= 42);
assert(!(101 <= o1));
}
Expand All @@ -76,7 +76,9 @@ constexpr bool test() {
int main(int, char**) {
test();
#if TEST_STD_VER >= 17
#if !(defined(TEST_COMPILER_NVCC) && _LIBCUDACXX_CUDACC_VER < 1103000 && defined(TEST_COMPILER_CLANG))
static_assert(test());
#endif // !(defined(TEST_COMPILER_NVCC) && _LIBCUDACXX_CUDACC_VER < 1103000 && defined(TEST_COMPILER_CLANG))
#endif

return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ constexpr bool test() {
typedef optional<T> O;

constexpr T val(2);
constexpr O o1; // disengaged
constexpr O o2{1}; // engaged
constexpr O o3{val}; // engaged
O o1; // disengaged
O o2{1}; // engaged
O o3{val}; // engaged

assert((o1 < T(1)));
assert(!(o2 < T(1))); // equal
Expand All @@ -57,13 +57,13 @@ constexpr bool test() {
}
{
using O = optional<int>;
constexpr O o1(42);
O o1(42);
assert(o1 < 101l);
assert(!(42l < o1));
}
{
using O = optional<const int>;
constexpr O o1(42);
O o1(42);
assert(o1 < 101);
assert(!(42 < o1));
}
Expand All @@ -74,7 +74,9 @@ constexpr bool test() {
int main(int, char**) {
test();
#if TEST_STD_VER >= 17
#if !(defined(TEST_COMPILER_NVCC) && _LIBCUDACXX_CUDACC_VER < 1103000 && defined(TEST_COMPILER_CLANG))
static_assert(test());
#endif // !(defined(TEST_COMPILER_NVCC) && _LIBCUDACXX_CUDACC_VER < 1103000 && defined(TEST_COMPILER_CLANG))
#endif

return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ constexpr bool test() {
typedef optional<T> O;

constexpr T val(2);
constexpr O o1; // disengaged
constexpr O o2{1}; // engaged
constexpr O o3{val}; // engaged
O o1; // disengaged
O o2{1}; // engaged
O o3{val}; // engaged

assert((o1 != T(1)));
assert(!(o2 != T(1)));
Expand All @@ -57,13 +57,13 @@ constexpr bool test() {
}
{
using O = optional<int>;
constexpr O o1(42);
O o1(42);
assert(o1 != 101l);
assert(!(42l != o1));
}
{
using O = optional<const int>;
constexpr O o1(42);
O o1(42);
assert(o1 != 101);
assert(!(42 != o1));
}
Expand All @@ -74,7 +74,9 @@ constexpr bool test() {
int main(int, char**) {
test();
#if TEST_STD_VER >= 17
#if !(defined(TEST_COMPILER_NVCC) && _LIBCUDACXX_CUDACC_VER < 1103000 && defined(TEST_COMPILER_CLANG))
static_assert(test());
#endif // !(defined(TEST_COMPILER_NVCC) && _LIBCUDACXX_CUDACC_VER < 1103000 && defined(TEST_COMPILER_CLANG))
#endif

return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,16 @@ TEST_CONSTEXPR_CXX17 bool test_nontrivial() {
int main(int, char**) {
test();
test_nontrivial();
#if !(defined(TEST_COMPILER_NVCC) && _LIBCUDACXX_CUDACC_VER < 1103000 && defined(TEST_COMPILER_CLANG))
// GCC <9 incorrectly trips on the assertions in this, so disable it there
#if TEST_STD_VER > 14 && (!defined(TEST_COMPILER_GCC) || __GNUC__ < 9)
static_assert(test(), "");
#endif
#endif // TEST_STD_VER > 14 && (!defined(TEST_COMPILER_GCC) || __GNUC__ < 9)
#if TEST_STD_VER > 17
#if defined(_LIBCUDACXX_ADDRESSOF)
static_assert(test_nontrivial());
#endif
#endif
#endif // defined(_LIBCUDACXX_ADDRESSOF)
#endif // TEST_STD_VER > 17
#endif // !(defined(TEST_COMPILER_NVCC) && _LIBCUDACXX_CUDACC_VER < 1103000 && defined(TEST_COMPILER_CLANG))
return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ constexpr bool test() {
typedef int T;
typedef optional<T> O;

constexpr O o1; // disengaged
constexpr O o2{1}; // engaged
O o1; // disengaged
O o2{1}; // engaged

assert( (nullopt == o1));
assert(!(nullopt == o2));
Expand All @@ -46,7 +46,9 @@ constexpr bool test() {
int main(int, char**) {
test();
#if TEST_STD_VER >= 17
#if !(defined(TEST_COMPILER_NVCC) && _LIBCUDACXX_CUDACC_VER < 1103000 && defined(TEST_COMPILER_CLANG))
static_assert(test());
#endif // !(defined(TEST_COMPILER_NVCC) && _LIBCUDACXX_CUDACC_VER < 1103000 && defined(TEST_COMPILER_CLANG))
#endif

return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ constexpr bool test() {
typedef int T;
typedef optional<T> O;

constexpr O o1; // disengaged
constexpr O o2{1}; // engaged
O o1; // disengaged
O o2{1}; // engaged

assert(!(nullopt > o1));
assert(!(nullopt > o2));
Expand All @@ -46,7 +46,9 @@ constexpr bool test() {
int main(int, char**) {
test();
#if TEST_STD_VER >= 17
#if !(defined(TEST_COMPILER_NVCC) && _LIBCUDACXX_CUDACC_VER < 1103000 && defined(TEST_COMPILER_CLANG))
static_assert(test());
#endif // !(defined(TEST_COMPILER_NVCC) && _LIBCUDACXX_CUDACC_VER < 1103000 && defined(TEST_COMPILER_CLANG))
#endif

return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ constexpr bool test() {
typedef int T;
typedef optional<T> O;

constexpr O o1; // disengaged
constexpr O o2{1}; // engaged
O o1; // disengaged
O o2{1}; // engaged

assert( (nullopt >= o1));
assert(!(nullopt >= o2));
Expand All @@ -46,7 +46,9 @@ constexpr bool test() {
int main(int, char**) {
test();
#if TEST_STD_VER >= 17
#if !(defined(TEST_COMPILER_NVCC) && _LIBCUDACXX_CUDACC_VER < 1103000 && defined(TEST_COMPILER_CLANG))
static_assert(test());
#endif // !(defined(TEST_COMPILER_NVCC) && _LIBCUDACXX_CUDACC_VER < 1103000 && defined(TEST_COMPILER_CLANG))
#endif

return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ constexpr bool test() {
typedef int T;
typedef optional<T> O;

constexpr O o1; // disengaged
constexpr O o2{1}; // engaged
O o1; // disengaged
O o2{1}; // engaged

assert( (nullopt <= o1));
assert( (nullopt <= o2));
Expand All @@ -47,7 +47,9 @@ constexpr bool test() {
int main(int, char**) {
test();
#if TEST_STD_VER >= 17
#if !(defined(TEST_COMPILER_NVCC) && _LIBCUDACXX_CUDACC_VER < 1103000 && defined(TEST_COMPILER_CLANG))
static_assert(test());
#endif // !(defined(TEST_COMPILER_NVCC) && _LIBCUDACXX_CUDACC_VER < 1103000 && defined(TEST_COMPILER_CLANG))
#endif

return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ constexpr bool test() {
typedef int T;
typedef optional<T> O;

constexpr O o1; // disengaged
constexpr O o2{1}; // engaged
O o1; // disengaged
O o2{1}; // engaged

assert(!(nullopt < o1));
assert( (nullopt < o2));
Expand All @@ -46,7 +46,9 @@ constexpr bool test() {
int main(int, char**) {
test();
#if TEST_STD_VER >= 17
#if !(defined(TEST_COMPILER_NVCC) && _LIBCUDACXX_CUDACC_VER < 1103000 && defined(TEST_COMPILER_CLANG))
static_assert(test());
#endif // !(defined(TEST_COMPILER_NVCC) && _LIBCUDACXX_CUDACC_VER < 1103000 && defined(TEST_COMPILER_CLANG))
#endif

return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ constexpr bool test() {
typedef int T;
typedef optional<T> O;

constexpr O o1; // disengaged
constexpr O o2{1}; // engaged
O o1; // disengaged
O o2{1}; // engaged

assert(!(nullopt != o1));
assert( (nullopt != o2));
Expand All @@ -46,7 +46,9 @@ constexpr bool test() {
int main(int, char**) {
test();
#if TEST_STD_VER >= 17
#if !(defined(TEST_COMPILER_NVCC) && _LIBCUDACXX_CUDACC_VER < 1103000 && defined(TEST_COMPILER_CLANG))
static_assert(test());
#endif // !(defined(TEST_COMPILER_NVCC) && _LIBCUDACXX_CUDACC_VER < 1103000 && defined(TEST_COMPILER_CLANG))
#endif

return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,9 @@ int main(int, char**)
test_throws();

#if !defined(TEST_COMPILER_GCC) || __GNUC__ > 6
#if !(defined(TEST_COMPILER_NVCC) && _LIBCUDACXX_CUDACC_VER < 1103000 && defined(TEST_COMPILER_CLANG))
static_assert(pr38638(3) == 5, "");
#endif // !(defined(TEST_COMPILER_NVCC) && _LIBCUDACXX_CUDACC_VER < 1103000 && defined(TEST_COMPILER_CLANG))
#endif // !defined(TEST_COMPILER_GCC) || __GNUC__ > 6

return 0;
Expand Down
Loading

0 comments on commit b92504b

Please sign in to comment.