diff --git a/.github/workflows/clang-c++23.yml b/.github/workflows/clang-c++23.yml new file mode 100644 index 000000000..542f13795 --- /dev/null +++ b/.github/workflows/clang-c++23.yml @@ -0,0 +1,163 @@ +name: clang-c++23 +on: + push: + branches: [ master, development, pull-request/* ] + pull_request: + branches: [ master, pull-request/* ] + +jobs: + + build-clang-cpp23-linux-no-stl: + name: Clang C++23 Linux - No STL + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-24.04] + + steps: + - uses: actions/checkout@v3 + + - name: Build + run: | + export CC=clang-18 + export CXX=clang++-18 + export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 + cmake -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=23 ./ + clang-18 --version + make + + - name: Run tests + run: ./test/etl_tests + + build-clang-cpp23-linux-stl-force-cpp03: + name: Clang C++23 Linux - STL - Force C++03 + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-24.04] + + steps: + - uses: actions/checkout@v3 + + - name: Build + run: | + export CC=clang-18 + export CXX=clang++-18 + export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 + cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=23 ./ + clang-18 --version + make + + - name: Run tests + run: ./test/etl_tests + + build-clang-cpp23-linux-no-stl-force-cpp03: + name: Clang C++23 Linux - No STL - Force C++03 + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-24.04] + + steps: + - uses: actions/checkout@v3 + + - name: Build + run: | + export CC=clang-18 + export CXX=clang++-18 + export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 + cmake -D BUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=23 ./ + clang-18 --version + make + + - name: Run tests + run: ./test/etl_tests + + build-clang-cpp23-osx-stl: + name: Clang C++23 OSX - STL + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [macos-12] + + steps: + - uses: actions/checkout@v3 + + - name: Build + run: | + export CC=clang + export CXX=clang++ + export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 + cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=23 ./ + clang --version + make + + - name: Run tests + run: ./test/etl_tests + + build-clang-cpp23-osx-no-stl: + name: Clang C++23 OSX - No STL + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [macos-12] + + steps: + - uses: actions/checkout@v3 + + - name: Build + run: | + export CC=clang + export CXX=clang++ + export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 + cmake -D BUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=23 ./ + clang --version + make + + - name: Run tests + run: ./test/etl_tests + + build-clang-cpp23-osx-stl-force-cpp03: + name: Clang C++23 OSX - STL - Force C++03 + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [macos-12] + + steps: + - uses: actions/checkout@v3 + + - name: Build + run: | + export CC=clang + export CXX=clang++ + export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 + cmake -D BUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=23 ./ + clang --version + make + + - name: Run tests + run: ./test/etl_tests + + build-clang-cpp23-osx-no-stl-force-cpp03: + name: Clang C++23 OSX - No STL - Force C++03 + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [macos-12] + + steps: + - uses: actions/checkout@v3 + + - name: Build + run: | + export CC=clang + export CXX=clang++ + export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 + cmake -D BUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=23 ./ + clang --version + make + + - name: Run tests + run: ./test/etl_tests + diff --git a/.github/workflows/gcc-c++23.yml b/.github/workflows/gcc-c++23.yml new file mode 100644 index 000000000..dc5ddd7c2 --- /dev/null +++ b/.github/workflows/gcc-c++23.yml @@ -0,0 +1,96 @@ +name: gcc-c++23 +on: + push: + branches: [ master, development, pull-request/* ] + pull_request: + branches: [ master, pull-request/* ] + +jobs: + + build-gcc-cpp23-linux-stl: + name: GCC C++23 Linux - STL + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-24.04] + + steps: + - uses: actions/checkout@v3 + + - name: Build + run: | + export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 + export CC=gcc + export CXX=g++ + cmake -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=23 ./ + gcc --version + make + + - name: Run tests + run: ./test/etl_tests + + build-gcc-cpp23-linux-no-stl: + name: GCC C++23 Linux - No STL + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-24.04] + + steps: + - uses: actions/checkout@v3 + + - name: Build + run: | + export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 + export CC=gcc + export CXX=g++ + cmake -DBUILD_TESTS=ON -DNO_STL=ON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=OFF -DETL_CXX_STANDARD=23 ./ + gcc --version + make + + - name: Run tests + run: ./test/etl_tests + + build-gcc-cpp23-linux-stl-force-cpp03: + name: GCC C++23 Linux - STL - Force C++03 + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-24.04] + + steps: + - uses: actions/checkout@v3 + + - name: Build + run: | + export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 + export CC=gcc + export CXX=g++ + cmake -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=23 ./ + gcc --version + make + + - name: Run tests + run: ./test/etl_tests + + build-gcc-cpp23-linux-no-stl-force-cpp03: + name: GCC C++23 Linux - No STL - Force C++03 + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-24.04] + + steps: + - uses: actions/checkout@v3 + + - name: Build + run: | + export ASAN_OPTIONS=alloc_dealloc_mismatch=0,detect_leaks=0 + export CC=gcc + export CXX=g++ + cmake -DBUILD_TESTS=ON -DNO_STL=OON -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03=ON -DETL_CXX_STANDARD=23 ./ + gcc --version + make + + - name: Run tests + run: ./test/etl_tests \ No newline at end of file diff --git a/include/etl/frame_check_sequence.h b/include/etl/frame_check_sequence.h index ec67e1bac..1e6a1a0b4 100644 --- a/include/etl/frame_check_sequence.h +++ b/include/etl/frame_check_sequence.h @@ -107,7 +107,7 @@ namespace etl //************************************************************************* /// Default constructor. //************************************************************************* - frame_check_sequence() + ETL_CONSTEXPR14 frame_check_sequence() { reset(); } @@ -118,7 +118,7 @@ namespace etl /// \param end End of the range. //************************************************************************* template - frame_check_sequence(TIterator begin, const TIterator end) + ETL_CONSTEXPR14 frame_check_sequence(TIterator begin, const TIterator end) { ETL_STATIC_ASSERT(sizeof(typename etl::iterator_traits::value_type) == 1, "Type not supported"); @@ -129,7 +129,7 @@ namespace etl //************************************************************************* /// Resets the FCS to the initial state. //************************************************************************* - void reset() + ETL_CONSTEXPR14 void reset() { frame_check = policy.initial(); } @@ -140,7 +140,7 @@ namespace etl /// \param end //************************************************************************* template - void add(TIterator begin, const TIterator end) + ETL_CONSTEXPR23 void add(TIterator begin, const TIterator end) { ETL_STATIC_ASSERT(sizeof(typename etl::iterator_traits::value_type) == 1, "Type not supported"); @@ -154,7 +154,7 @@ namespace etl //************************************************************************* /// \param value The uint8_t to add to the FCS. //************************************************************************* - void add(uint8_t value_) + ETL_CONSTEXPR23 void add(uint8_t value_) { frame_check = policy.add(frame_check, value_); } @@ -162,7 +162,7 @@ namespace etl //************************************************************************* /// Gets the FCS value. //************************************************************************* - value_type value() const + ETL_CONSTEXPR14 value_type value() const { return policy.final(frame_check); } diff --git a/include/etl/platform.h b/include/etl/platform.h index 17c7961d5..afb1ae365 100644 --- a/include/etl/platform.h +++ b/include/etl/platform.h @@ -351,8 +351,10 @@ SOFTWARE. // C++23 #if ETL_USING_CPP23 && !defined(ETL_FORCE_NO_ADVANCED_CPP) #define ETL_ASSUME(expression) [[assume(expression)]] + #define ETL_CONSTEXPR23 constexpr #else #define ETL_ASSUME ETL_DO_NOTHING + #define ETL_CONSTEXPR23 #endif //************************************* diff --git a/include/etl/private/crc_implementation.h b/include/etl/private/crc_implementation.h index d94f0f181..4061cd7f5 100644 --- a/include/etl/private/crc_implementation.h +++ b/include/etl/private/crc_implementation.h @@ -183,7 +183,7 @@ namespace etl template static typename etl::enable_if<(Accumulator_Bits > Chunk_Bits) && Reflect, TAccumulator>::type - crc_update_chunk(TAccumulator crc, uint8_t value, const TAccumulator table[]) + ETL_CONSTEXPR14 crc_update_chunk(TAccumulator crc, uint8_t value, const TAccumulator table[]) { value &= Chunk_Mask; @@ -241,7 +241,7 @@ namespace etl struct crc_table { //************************************************************************* - TAccumulator add(TAccumulator crc, uint8_t value) const + ETL_CONSTEXPR23 TAccumulator add(TAccumulator crc, uint8_t value) const { static ETL_CONSTANT TAccumulator table[4U] = { @@ -276,7 +276,7 @@ namespace etl struct crc_table { //************************************************************************* - TAccumulator add(TAccumulator crc, uint8_t value) const + ETL_CONSTEXPR23 TAccumulator add(TAccumulator crc, uint8_t value) const { static ETL_CONSTANT TAccumulator table[16U] = { @@ -319,7 +319,7 @@ namespace etl struct crc_table { //************************************************************************* - TAccumulator add(TAccumulator crc, uint8_t value) const + ETL_CONSTEXPR23 TAccumulator add(TAccumulator crc, uint8_t value) const { static ETL_CONSTANT TAccumulator table[256U] = { @@ -608,14 +608,14 @@ namespace etl typedef accumulator_type value_type; //************************************************************************* - ETL_CONSTEXPR accumulator_type initial() const + ETL_CONSTEXPR14 accumulator_type initial() const { return TCrcParameters::Reflect ? etl::reverse_bits_const::value : TCrcParameters::Initial; } //************************************************************************* - accumulator_type final(accumulator_type crc) const + ETL_CONSTEXPR14 accumulator_type final(accumulator_type crc) const { return crc ^ TCrcParameters::Xor_Out; } @@ -636,7 +636,7 @@ namespace etl typedef accumulator_type value_type; //************************************************************************* - ETL_CONSTEXPR accumulator_type initial() const + ETL_CONSTEXPR14 accumulator_type initial() const { return TCrcParameters::Reflect ? etl::reverse_bits_const::value : TCrcParameters::Initial; @@ -664,7 +664,7 @@ namespace etl typedef accumulator_type value_type; //************************************************************************* - ETL_CONSTEXPR accumulator_type initial() const + ETL_CONSTEXPR14 accumulator_type initial() const { return TCrcParameters::Reflect ? etl::reverse_bits_const::value : TCrcParameters::Initial; @@ -691,7 +691,7 @@ namespace etl //************************************************************************* /// Default constructor. //************************************************************************* - crc_type() + ETL_CONSTEXPR14 crc_type() { this->reset(); } @@ -702,7 +702,7 @@ namespace etl /// \param end End of the range. //************************************************************************* template - crc_type(TIterator begin, const TIterator end) + ETL_CONSTEXPR14 crc_type(TIterator begin, const TIterator end) { this->reset(); this->add(begin, end); diff --git a/include/etl/profiles/determine_compiler_language_support.h b/include/etl/profiles/determine_compiler_language_support.h index e8a004411..8f0b39393 100644 --- a/include/etl/profiles/determine_compiler_language_support.h +++ b/include/etl/profiles/determine_compiler_language_support.h @@ -37,8 +37,12 @@ SOFTWARE. // Determine C++23 support #if !defined(ETL_CPP23_SUPPORTED) +#if defined(__cplusplus) && (__cplusplus >= 202302L) + #define ETL_CPP23_SUPPORTED 1 +#else #define ETL_CPP23_SUPPORTED 0 #endif +#endif #if ETL_CPP23_SUPPORTED #define ETL_CPP11_SUPPORTED 1 diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index eaf80ec13..86826396d 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -310,9 +310,12 @@ elseif (ETL_CXX_STANDARD MATCHES "14") elseif (ETL_CXX_STANDARD MATCHES "17") message(STATUS "Compiling for C++17") set_property(TARGET etl_tests PROPERTY CXX_STANDARD 17) -else() +elseif (ETL_CXX_STANDARD MATCHES "20") message(STATUS "Compiling for C++20") set_property(TARGET etl_tests PROPERTY CXX_STANDARD 20) +else() + message(STATUS "Compiling for C++23") + set_property(TARGET etl_tests PROPERTY CXX_STANDARD 23) endif() if (NO_STL OR ETL_NO_STL) diff --git a/test/test_etl_traits.cpp b/test/test_etl_traits.cpp index a071960e4..2ef48dc82 100644 --- a/test/test_etl_traits.cpp +++ b/test/test_etl_traits.cpp @@ -84,7 +84,9 @@ namespace CHECK_EQUAL(ETL_VERSION_MINOR, etl::traits::version_minor); CHECK_EQUAL(ETL_VERSION_PATCH, etl::traits::version_patch); CHECK_EQUAL(ETL_VERSION_VALUE, etl::traits::version); -#if ETL_USING_CPP20 +#if ETL_USING_CPP23 + CHECK_EQUAL(23, etl::traits::language_standard); +#elif ETL_USING_CPP20 CHECK_EQUAL(20, etl::traits::language_standard); #elif ETL_USING_CPP17 CHECK_EQUAL(17, etl::traits::language_standard); diff --git a/test/test_mem_cast_ptr.cpp b/test/test_mem_cast_ptr.cpp index ec8eadefd..49fecb9a6 100644 --- a/test/test_mem_cast_ptr.cpp +++ b/test/test_mem_cast_ptr.cpp @@ -72,7 +72,7 @@ namespace return reinterpret_cast(uintptr_t(i)); } - typename std::aligned_storage::type buffer; + etl::aligned_storage::type buffer; SUITE(test_mem_cast_ptr) { diff --git a/test/test_murmur3.cpp b/test/test_murmur3.cpp index c8dc0d81f..72b1c3b0c 100644 --- a/test/test_murmur3.cpp +++ b/test/test_murmur3.cpp @@ -35,6 +35,7 @@ SOFTWARE. #include #include +#include "etl/alignment.h" #include "etl/murmur3.h" namespace @@ -44,7 +45,7 @@ namespace //************************************************************************* TEST(test_murmur3_32_constructor) { - typename std::aligned_storage::value>::type storage[10]; + typename etl::aligned_storage::value>::type storage[10]; std::string data("123456789"); char* begin = (char*)&storage[0]; @@ -61,7 +62,7 @@ namespace //************************************************************************* TEST(test_murmur3_32_add_values) { - typename std::aligned_storage::value>::type storage[10]; + typename etl::aligned_storage::value>::type storage[10]; std::string data("123456789"); char* begin = (char*)&storage[0]; @@ -85,7 +86,7 @@ namespace //************************************************************************* TEST(test_murmur3_32_add_range) { - typename std::aligned_storage::value>::type storage[10]; + typename etl::aligned_storage::value>::type storage[10]; std::string data("123456789"); char* begin = (char*)&storage[0];