diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index cc59031..8d7085b 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -10,16 +10,14 @@ jobs: matrix: config: # https://github.com/actions/virtual-environments/tree/main/images/linux - - { os: "ubuntu-18.04", cc: "gcc-7", cxx: "g++-7" } - - { os: "ubuntu-18.04", cc: "gcc-8", cxx: "g++-8" } - - { os: "ubuntu-18.04", cc: "gcc-9", cxx: "g++-9" } - - { os: "ubuntu-18.04", cc: "gcc-10", cxx: "g++-10" } - - { os: "ubuntu-18.04", cc: "clang-5.0", cxx: "clang++-5.0" } - - { os: "ubuntu-18.04", cc: "clang-6.0", cxx: "clang++-6.0" } - - { os: "ubuntu-18.04", cc: "clang-7", cxx: "clang++-7" } - - { os: "ubuntu-18.04", cc: "clang-8", cxx: "clang++-8" } - - { os: "ubuntu-18.04", cc: "clang-9", cxx: "clang++-9" } - - { os: "ubuntu-18.04", cc: "clang-10", cxx: "clang++-10" } + - { os: "ubuntu-20.04", cc: "gcc-7", cxx: "g++-7" } + - { os: "ubuntu-20.04", cc: "gcc-8", cxx: "g++-8" } + - { os: "ubuntu-20.04", cc: "gcc-9", cxx: "g++-9" } + - { os: "ubuntu-20.04", cc: "gcc-10", cxx: "g++-10" } + - { os: "ubuntu-20.04", cc: "clang-7", cxx: "clang++-7" } + - { os: "ubuntu-20.04", cc: "clang-8", cxx: "clang++-8" } + - { os: "ubuntu-20.04", cc: "clang-9", cxx: "clang++-9" } + - { os: "ubuntu-20.04", cc: "clang-10", cxx: "clang++-10" } name: "${{matrix.config.cxx}}" steps: - name: Setup diff --git a/CMakeLists.txt b/CMakeLists.txt index 388ba98..50cf4a4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,17 @@ add_library(${PROJECT_NAME} INTERFACE) target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_17) target_include_directories(${PROJECT_NAME} INTERFACE headers) +target_compile_options(${PROJECT_NAME} + INTERFACE + $<$,$>: + -Wno-c++98-compat-pedantic + -Wno-covered-switch-default + -Wno-ctad-maybe-unsupported + -Wno-old-style-cast + -Wno-shadow + -Wno-unknown-warning-option + -Wno-weak-vtables>) + if(BUILD_AS_STANDALONE) option(BUILD_WITH_UNTESTS "Build with unit tests" ON) if(BUILD_WITH_UNTESTS) diff --git a/README.md b/README.md index c167f9d..4f1792d 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ ## Requirements - [gcc](https://www.gnu.org/software/gcc/) **>= 7** -- [clang](https://clang.llvm.org/) **>= 5.0** +- [clang](https://clang.llvm.org/) **>= 7** - [msvc](https://visualstudio.microsoft.com/) **>= 2017** ## Installation diff --git a/headers/enum.hpp/enum.hpp b/headers/enum.hpp/enum.hpp index d616c18..b1e67cb 100644 --- a/headers/enum.hpp/enum.hpp +++ b/headers/enum.hpp/enum.hpp @@ -260,30 +260,28 @@ namespace enum_hpp::detail { ENUM_HPP_GENERATE_NAMES(Fields) }\ };\ public:\ - static constexpr underlying_type to_underlying(enum_type e) noexcept {\ + [[maybe_unused]] static constexpr underlying_type to_underlying(enum_type e) noexcept {\ return static_cast(e);\ }\ - \ - static constexpr std::optional to_string(enum_type e) noexcept {\ + [[maybe_unused]] static constexpr std::optional to_string(enum_type e) noexcept {\ switch ( e ) {\ ENUM_HPP_GENERATE_VALUE_TO_NAME_CASES(Enum, Fields)\ default: return std::nullopt;\ }\ }\ - static constexpr std::string_view to_string_or_empty(enum_type e) noexcept {\ + [[maybe_unused]] static constexpr std::string_view to_string_or_empty(enum_type e) noexcept {\ if ( auto s = to_string(e) ) {\ return *s;\ }\ return ::enum_hpp::empty_string;\ }\ - static std::string_view to_string_or_throw(enum_type e) {\ + [[maybe_unused]] static std::string_view to_string_or_throw(enum_type e) {\ if ( auto s = to_string(e) ) {\ return *s;\ }\ ::enum_hpp::detail::throw_exception_with(#Enum "_traits::to_string_or_throw(): invalid argument");\ }\ - \ - static constexpr std::optional from_string(std::string_view name) noexcept {\ + [[maybe_unused]] static constexpr std::optional from_string(std::string_view name) noexcept {\ for ( std::size_t i = 0; i < size; ++i) {\ if ( name == names[i] ) {\ return values[i];\ @@ -291,52 +289,49 @@ namespace enum_hpp::detail }\ return std::nullopt;\ }\ - static constexpr enum_type from_string_or_default(std::string_view name, enum_type def) noexcept {\ + [[maybe_unused]] static constexpr enum_type from_string_or_default(std::string_view name, enum_type def) noexcept {\ if ( auto e = from_string(name) ) {\ return *e;\ }\ return def;\ }\ - static enum_type from_string_or_throw(std::string_view name) {\ + [[maybe_unused]] static enum_type from_string_or_throw(std::string_view name) {\ if ( auto e = from_string(name) ) {\ return *e;\ }\ ::enum_hpp::detail::throw_exception_with(#Enum "_traits::from_string_or_throw(): invalid argument");\ }\ - \ - static constexpr std::optional to_index(enum_type e) noexcept {\ + [[maybe_unused]] static constexpr std::optional to_index(enum_type e) noexcept {\ switch ( e ) {\ ENUM_HPP_GENERATE_VALUE_TO_INDEX_CASES(Enum, Fields)\ default: return std::nullopt;\ }\ }\ - \ - static constexpr std::size_t to_index_or_invalid(enum_type e) noexcept {\ + [[maybe_unused]] static constexpr std::size_t to_index_or_invalid(enum_type e) noexcept {\ if ( auto i = to_index(e) ) {\ return *i;\ }\ return ::enum_hpp::invalid_index;\ }\ - static std::size_t to_index_or_throw(enum_type e) {\ + [[maybe_unused]] static std::size_t to_index_or_throw(enum_type e) {\ if ( auto i = to_index(e) ) {\ return *i;\ }\ ::enum_hpp::detail::throw_exception_with(#Enum "_traits::to_index_or_throw(): invalid argument");\ }\ - \ - static constexpr std::optional from_index(std::size_t index) noexcept {\ + [[maybe_unused]] static constexpr std::optional from_index(std::size_t index) noexcept {\ if ( index < size ) {\ return values[index];\ }\ return std::nullopt;\ }\ - static constexpr enum_type from_index_or_default(std::size_t index, enum_type def) noexcept {\ + [[maybe_unused]] static constexpr enum_type from_index_or_default(std::size_t index, enum_type def) noexcept {\ if ( auto e = from_index(index) ) {\ return *e;\ }\ return def;\ }\ - static enum_type from_index_or_throw(std::size_t index) {\ + [[maybe_unused]] static enum_type from_index_or_throw(std::size_t index) {\ if ( auto e = from_index(index) ) {\ return *e;\ }\ diff --git a/headers/enum.hpp/enum_bitflags.hpp b/headers/enum.hpp/enum_bitflags.hpp index a9eccd1..a8645a7 100644 --- a/headers/enum.hpp/enum_bitflags.hpp +++ b/headers/enum.hpp/enum_bitflags.hpp @@ -58,7 +58,7 @@ namespace enum_hpp::bitflags constexpr bitflags& toggle(bitflags flags) noexcept { flags_ ^= flags.flags_; return *this; - }; + } constexpr bitflags& clear(bitflags flags) noexcept { flags_ &= ~flags.flags_; diff --git a/untests/CMakeLists.txt b/untests/CMakeLists.txt index 5e40ac3..035435b 100644 --- a/untests/CMakeLists.txt +++ b/untests/CMakeLists.txt @@ -25,7 +25,10 @@ target_compile_options(${PROJECT_NAME} $<$: /WX /W4> PRIVATE - $<$,$,$>: - -Werror -Wall -Wextra -Wpedantic>) + $<$: + -Werror -Wall -Wextra -Wpedantic> + PRIVATE + $<$,$>: + -Werror -Weverything -Wconversion>) add_test(${PROJECT_NAME} ${PROJECT_NAME})