Skip to content

Commit

Permalink
add gcc13 and clang18 to build_tests.sh, and fix new warnings issued …
Browse files Browse the repository at this point in the history
…by clang18
  • Loading branch information
hurchalla committed Mar 11, 2024
1 parent 8186d90 commit 89a3963
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 10 deletions.
25 changes: 22 additions & 3 deletions build_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@



while getopts ":m:c:h-:rs" opt; do
while getopts ":m:l:c:h-:rs" opt; do
case $opt in
h)
;&
Expand All @@ -171,6 +171,9 @@ while getopts ":m:c:h-:rs" opt; do
m)
mode=$OPTARG
;;
l)
library=$OPTARG
;;
r)
run_tests=true
;;
Expand All @@ -195,6 +198,11 @@ if [ -z "$mode" ]; then
mode=Debug
fi

if [ -n "$library" ]; then
cpp_stdlib="-stdlib=$library"
fi



# Compiler commands
if [ "${compiler,,}" = "gcc" ] || [ "${compiler,,}" = "g++" ]; then
Expand All @@ -211,6 +219,11 @@ elif [ "${compiler,,}" = "gcc-10" ] || [ "${compiler,,}" = "g++-10" ] ||
cmake_cpp_compiler=-DCMAKE_CXX_COMPILER=g++-10
cmake_c_compiler=-DCMAKE_C_COMPILER=gcc-10
compiler_name=gcc10
elif [ "${compiler,,}" = "gcc-13" ] || [ "${compiler,,}" = "g++-13" ] ||
[ "${compiler,,}" = "gcc13" ] || [ "${compiler,,}" = "g++13" ]; then
cmake_cpp_compiler=-DCMAKE_CXX_COMPILER=g++-13
cmake_c_compiler=-DCMAKE_C_COMPILER=gcc-13
compiler_name=gcc13
elif [ "${compiler,,}" = "clang" ] || [ "${compiler,,}" = "clang++" ]; then
cmake_cpp_compiler=-DCMAKE_CXX_COMPILER=clang++
cmake_c_compiler=-DCMAKE_C_COMPILER=clang
Expand All @@ -230,6 +243,11 @@ elif [ "${compiler,,}" = "clang-10" ] || [ "${compiler,,}" = "clang++-10" ] ||
cmake_cpp_compiler=-DCMAKE_CXX_COMPILER=clang++-10
cmake_c_compiler=-DCMAKE_C_COMPILER=clang-10
compiler_name=clang10
elif [ "${compiler,,}" = "clang-18" ] || [ "${compiler,,}" = "clang++-18" ] ||
[ "${compiler,,}" = "clang18" ] || [ "${compiler,,}" = "clang++18" ]; then
cmake_cpp_compiler=-DCMAKE_CXX_COMPILER=clang++-18
cmake_c_compiler=-DCMAKE_C_COMPILER=clang-18
compiler_name=clang18
elif [ "${compiler,,}" = "icc" ] || [ "${compiler,,}" = "icpc" ]; then
cmake_cpp_compiler=-DCMAKE_CXX_COMPILER=icpc
cmake_c_compiler=-DCMAKE_C_COMPILER=icc
Expand Down Expand Up @@ -434,7 +452,7 @@ if [ "${mode,,}" = "release" ]; then
mkdir -p $build_dir
cmake -S. -B./$build_dir -DTEST_HURCHALLA_LIBS=ON \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_FLAGS="$cpp_standard \
-DCMAKE_CXX_FLAGS="$cpp_standard $cpp_stdlib \
$test_avoid_cselect \
$gcc_static_analysis" "${clang_static_analysis[@]}" \
$cmake_cpp_compiler $cmake_c_compiler
Expand All @@ -449,7 +467,8 @@ elif [ "${mode,,}" = "debug" ]; then
cmake -S. -B./$build_dir -DTEST_HURCHALLA_LIBS=ON \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_EXE_LINKER_FLAGS="$clang_ubsan_link_flags" \
-DCMAKE_CXX_FLAGS="$cpp_standard $clang_ubsan $gcc_ubsan \
-DCMAKE_CXX_FLAGS="$cpp_standard $cpp_stdlib \
$clang_ubsan $gcc_ubsan \
$test_avoid_cselect \
$gcc_static_analysis" "${clang_static_analysis[@]}" \
$cmake_cpp_compiler $cmake_c_compiler
Expand Down
23 changes: 16 additions & 7 deletions include/hurchalla/util/sized_uint.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,37 +26,42 @@ template <int BITS, typename DUMMY=void> struct sized_uint
static constexpr bool is_valid = false;
using type = void;
};
// This section is only needed prior to C++17, and can cause deprecation
// warnings if enabled after C++17
#if __cplusplus < 201703L
template <int BITS, typename DUMMY>
constexpr bool sized_uint<BITS, DUMMY>::is_valid;

#endif

template <typename DUMMY> struct sized_uint<8, DUMMY>
{
static constexpr bool is_valid = true;
using type = std::uint8_t;
};
template <typename DUMMY> constexpr bool sized_uint<8, DUMMY>::is_valid;

template <typename DUMMY> struct sized_uint<16, DUMMY>
{
static constexpr bool is_valid = true;
using type = std::uint16_t;
};
template <typename DUMMY> constexpr bool sized_uint<16, DUMMY>::is_valid;

template <typename DUMMY> struct sized_uint<32, DUMMY>
{
static constexpr bool is_valid = true;
using type = std::uint32_t;
};
template <typename DUMMY> constexpr bool sized_uint<32, DUMMY>::is_valid;

template <typename DUMMY> struct sized_uint<64, DUMMY>
{
static constexpr bool is_valid = true;
using type = std::uint64_t;
};

// This section is only needed prior to C++17, and can cause deprecation
// warnings if enabled after C++17
#if __cplusplus < 201703L
template <typename DUMMY> constexpr bool sized_uint<8, DUMMY>::is_valid;
template <typename DUMMY> constexpr bool sized_uint<16, DUMMY>::is_valid;
template <typename DUMMY> constexpr bool sized_uint<32, DUMMY>::is_valid;
template <typename DUMMY> constexpr bool sized_uint<64, DUMMY>::is_valid;
#endif

#if (HURCHALLA_COMPILER_HAS_UINT128_T())
// Some compilers support __uint128_t, so we'll specialize with it if possible
Expand All @@ -65,15 +70,19 @@ template <typename DUMMY> constexpr bool sized_uint<64, DUMMY>::is_valid;
static constexpr bool is_valid = true;
using type = __uint128_t;
};
# if __cplusplus < 201703L
template <typename DUMMY> constexpr bool sized_uint<128, DUMMY>::is_valid;
# endif
#elif (HURCHALLA_TARGET_BIT_WIDTH >= 128)
// presumably if a CPU target is >= 128bit, type uint128_t will exist.
template <typename DUMMY> struct sized_uint<128, DUMMY>
{
static constexpr bool is_valid = true;
using type = std::uint128_t;
};
# if __cplusplus < 201703L
template <typename DUMMY> constexpr bool sized_uint<128, DUMMY>::is_valid;
# endif
#endif


Expand Down
8 changes: 8 additions & 0 deletions include/hurchalla/util/traits/ut_numeric_limits.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ struct ut_numeric_limits<__int128_t, U> {
static constexpr __int128_t signaling_NaN() noexcept { return 0; }
static constexpr __int128_t denorm_min() noexcept { return 0; }
};
// This section is only needed prior to C++17, and can cause deprecation
// warnings if enabled after C++17
#if __cplusplus < 201703L
template <typename U>
constexpr bool ut_numeric_limits<__int128_t, U>::is_specialized;
template <typename U>
Expand Down Expand Up @@ -202,6 +205,7 @@ template <typename U>
constexpr bool ut_numeric_limits<__int128_t, U>::traps;
template <typename U>
constexpr bool ut_numeric_limits<__int128_t, U>::tinyness_before;
#endif

template<typename U>
struct ut_numeric_limits<__uint128_t, U> {
Expand Down Expand Up @@ -243,6 +247,9 @@ struct ut_numeric_limits<__uint128_t, U> {
static constexpr __uint128_t signaling_NaN() noexcept { return 0; }
static constexpr __uint128_t denorm_min() noexcept { return 0; }
};
// This section is only needed prior to C++17, and can cause deprecation
// warnings if enabled after C++17
#if __cplusplus < 201703L
template <typename U>
constexpr bool ut_numeric_limits<__uint128_t, U>::is_specialized;
template <typename U>
Expand Down Expand Up @@ -289,6 +296,7 @@ template <typename U>
constexpr bool ut_numeric_limits<__uint128_t, U>::traps;
template <typename U>
constexpr bool ut_numeric_limits<__uint128_t, U>::tinyness_before;
#endif

#endif

Expand Down

0 comments on commit 89a3963

Please sign in to comment.