Skip to content

Commit

Permalink
be more specific with gcc versions when omiting bit field tests
Browse files Browse the repository at this point in the history
  • Loading branch information
davebayer committed Nov 19, 2024
1 parent f1b9640 commit 2ade9a8
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@

#include "test_macros.h"

#if defined(TEST_COMPILER_GCC) && ((TEST_GCC_VER >= 900 && TEST_GCC_VER < 903) || TEST_GCC_VER < 804)
# define OMIT_BITFIELD_ENUMS 1
#endif

enum class e_default
{
a = 0,
Expand Down Expand Up @@ -52,14 +56,14 @@ enum class e_bool : cuda::std::uint8_t
t = 1
};

#if !defined(TEST_COMPILER_GCC) || TEST_GCC_VER >= 903
#if !OMIT_BITFIELD_ENUMS
struct WithBitfieldEnums
{
e_default e1 : 3;
e_ushort e2 : 6;
e_bool e3 : 1;
};
#endif // !defined(TEST_COMPILER_GCC) || TEST_GCC_VER >= 903
#endif // !OMIT_BITFIELD_ENUMS

__host__ __device__ TEST_CONSTEXPR_CXX14 bool test()
{
Expand Down Expand Up @@ -88,15 +92,15 @@ __host__ __device__ TEST_CONSTEXPR_CXX14 bool test()
assert(cuda::std::numeric_limits<int>::min() == cuda::std::to_underlying(enum_min));
assert(cuda::std::numeric_limits<int>::max() == cuda::std::to_underlying(enum_max));

#if !defined(TEST_COMPILER_GCC) || TEST_GCC_VER >= 903
#if !OMIT_BITFIELD_ENUMS
WithBitfieldEnums bf{};
bf.e1 = static_cast<e_default>(3);
bf.e2 = e_ushort::e;
bf.e3 = e_bool::t;
assert(3 == cuda::std::to_underlying(bf.e1));
assert(25 == cuda::std::to_underlying(bf.e2));
assert(1 == cuda::std::to_underlying(bf.e3));
#endif // !defined(TEST_COMPILER_GCC) || TEST_GCC_VER >= 903
#endif // !OMIT_BITFIELD_ENUMS

return true;
}
Expand Down

0 comments on commit 2ade9a8

Please sign in to comment.