From 698ee0ecd1c7db1c9bd8260e38bf000cf5a95c7d Mon Sep 17 00:00:00 2001 From: Mark Gillard Date: Fri, 14 Oct 2022 13:18:24 +0300 Subject: [PATCH] fixes for latest MSVC also: - minor doc tweaks --- .clang-format | 2 +- docs/poxy.toml | 4 +-- include/toml++/impl/preprocessor.h | 9 +++-- tests/formatters.cpp | 54 +++++++++++++++--------------- tests/lib_catch2.h | 2 ++ tests/main.cpp | 5 +++ toml.hpp | 9 +++-- 7 files changed, 49 insertions(+), 36 deletions(-) diff --git a/.clang-format b/.clang-format index 83ae0ab..e3c1e57 100644 --- a/.clang-format +++ b/.clang-format @@ -31,7 +31,6 @@ AttributeMacros: - TOML_EMPTY_BASES - TOML_EXPORTED_CLASS - TOML_FLAGS_ENUM - - TOML_LIKELY_CASE - TOML_OPEN_ENUM - TOML_OPEN_FLAGS_ENUM - TOML_TRIVIAL_ABI @@ -175,6 +174,7 @@ StatementMacros: - TOML_EXTERN - TOML_EXTERNAL_LINKAGE - TOML_INTERNAL_LINKAGE + - TOML_LIKELY_CASE - TOML_MEMBER_ATTR - TOML_NEVER_INLINE - TOML_NODISCARD diff --git a/docs/poxy.toml b/docs/poxy.toml index f1f8ad9..5e1dfdb 100644 --- a/docs/poxy.toml +++ b/docs/poxy.toml @@ -18,7 +18,8 @@ extra_files = [ 'images/badge-TOML.svg', 'images/badge-gitter.svg' ] -html_header = '' +html_header = '' + [warnings] @@ -55,7 +56,6 @@ paths = [ 'images' ] [code_blocks] macros = [ 'TOML_[A-Z0-9_]+?', 'print_value' ] -string_literals = [ '_toml' ] diff --git a/include/toml++/impl/preprocessor.h b/include/toml++/impl/preprocessor.h index b3fe8ce..44c990a 100644 --- a/include/toml++/impl/preprocessor.h +++ b/include/toml++/impl/preprocessor.h @@ -464,6 +464,7 @@ __pragma(warning(disable : 4061)) \ __pragma(warning(disable : 4062)) \ __pragma(warning(disable : 4063)) \ + __pragma(warning(disable : 5262)) /* switch-case implicit fallthrough (false-positive) */ \ __pragma(warning(disable : 26819)) /* cg: unannotated fallthrough */ \ static_assert(true) @@ -475,9 +476,9 @@ __pragma(warning(disable : 4505)) /* unreferenced local function removed */ \ __pragma(warning(disable : 4514)) /* unreferenced inline function has been removed */ \ __pragma(warning(disable : 4582)) /* constructor is not implicitly called */ \ - __pragma(warning(disable : 4623)) /* default constructor was implicitly defined as deleted */ \ - __pragma(warning(disable : 4625)) /* copy constructor was implicitly defined as deleted */ \ - __pragma(warning(disable : 4626)) /* assignment operator was implicitly defined as deleted */ \ + __pragma(warning(disable : 4623)) /* default constructor was implicitly defined as deleted */ \ + __pragma(warning(disable : 4625)) /* copy constructor was implicitly defined as deleted */ \ + __pragma(warning(disable : 4626)) /* assignment operator was implicitly defined as deleted */ \ __pragma(warning(disable : 4710)) /* function not inlined */ \ __pragma(warning(disable : 4711)) /* function selected for automatic expansion */ \ __pragma(warning(disable : 4820)) /* N bytes padding added */ \ @@ -486,6 +487,7 @@ __pragma(warning(disable : 5027)) /* move assignment operator was implicitly defined as deleted */ \ __pragma(warning(disable : 5039)) /* potentially throwing function passed to 'extern "C"' function */ \ __pragma(warning(disable : 5045)) /* Compiler will insert Spectre mitigation */ \ + __pragma(warning(disable : 5264)) /* const variable is not used (false-positive) */ \ __pragma(warning(disable : 26451)) \ __pragma(warning(disable : 26490)) \ __pragma(warning(disable : 26495)) \ @@ -508,6 +510,7 @@ __pragma(warning(disable : 4348)) \ __pragma(warning(disable : 4668)) \ __pragma(warning(disable : 5105)) \ + __pragma(warning(disable : 5264)) \ TOML_DISABLE_CODE_ANALYSIS_WARNINGS; \ TOML_DISABLE_SWITCH_WARNINGS; \ TOML_DISABLE_SPAM_WARNINGS; \ diff --git a/tests/formatters.cpp b/tests/formatters.cpp index d6b0ddb..3f9778e 100644 --- a/tests/formatters.cpp +++ b/tests/formatters.cpp @@ -106,46 +106,46 @@ TEST_CASE("formatters") const auto data_date = toml::date{ 2021, 11, 2 }; const auto data_time = toml::time{ 20, 33, 0 }; const auto data = toml::table{ - { "integers"sv, + { "integers"sv, toml::table{ { "zero"sv, 0 }, - { "one"sv, 1 }, - { "dec"sv, 10 }, - { "bin"sv, 10, toml::value_flags::format_as_binary }, - { "oct"sv, 10, toml::value_flags::format_as_octal }, - { "hex"sv, 10, toml::value_flags::format_as_hexadecimal } } }, - { "floats"sv, + { "one"sv, 1 }, + { "dec"sv, 10 }, + { "bin"sv, 10, toml::value_flags::format_as_binary }, + { "oct"sv, 10, toml::value_flags::format_as_octal }, + { "hex"sv, 10, toml::value_flags::format_as_hexadecimal } } }, + { "floats"sv, toml::table{ { "pos_zero"sv, +0.0 }, - { "neg_zero"sv, -0.0 }, - { "one"sv, 1.0 }, - { "pos_inf"sv, +std::numeric_limits::infinity() }, - { "neg_inf"sv, -std::numeric_limits::infinity() }, - { "pos_nan"sv, +std::numeric_limits::quiet_NaN() }, - { "neg_nan"sv, -std::numeric_limits::quiet_NaN() } + { "neg_zero"sv, -0.0 }, + { "one"sv, 1.0 }, + { "pos_inf"sv, +std::numeric_limits::infinity() }, + { "neg_inf"sv, -std::numeric_limits::infinity() }, + { "pos_nan"sv, +std::numeric_limits::quiet_NaN() }, + { "neg_nan"sv, -std::numeric_limits::quiet_NaN() } } }, - { "dates and times"sv, + { "dates and times"sv, toml::table{ - { "dates"sv, toml::table{ { "val"sv, data_date } } }, + { "dates"sv, toml::table{ { "val"sv, data_date } } }, - { "times"sv, toml::table{ { "val"sv, data_time } } }, + { "times"sv, toml::table{ { "val"sv, data_time } } }, - { "date-times"sv, + { "date-times"sv, toml::table{ - { "local"sv, toml::table{ { "val"sv, toml::date_time{ data_date, data_time } } } }, - { "offset"sv, + { "local"sv, toml::table{ { "val"sv, toml::date_time{ data_date, data_time } } } }, + { "offset"sv, toml::table{ - { "val"sv, toml::date_time{ data_date, data_time, toml::time_offset{} } } } } } } } }, + { "val"sv, toml::date_time{ data_date, data_time, toml::time_offset{} } } } } } } } }, - { "bools"sv, + { "bools"sv, toml::table{ { "true"sv, true }, // - { "false"sv, false } } }, + { "false"sv, false } } }, - { - "strings"sv, - toml::array{ R"()"sv, + { + "strings"sv, + toml::array{ R"()"sv, R"(string)"sv, R"(string with a single quote in it: ')"sv, R"(string with a double quote in it: ")"sv, @@ -153,9 +153,9 @@ TEST_CASE("formatters") R"(a long string to force the array over multiple lines)"sv }, }, - { "a"sv, + { "a"sv, toml::table{ { "val", true }, - { "b"sv, toml::table{ { "val", true }, { "c"sv, toml::table{ { "val", true } } } } } } } + { "b"sv, toml::table{ { "val", true }, { "c"sv, toml::table{ { "val", true } } } } } } } }; diff --git a/tests/lib_catch2.h b/tests/lib_catch2.h index 9a04913..01a36ac 100644 --- a/tests/lib_catch2.h +++ b/tests/lib_catch2.h @@ -20,6 +20,8 @@ #pragma warning(disable : 4365) #pragma warning(disable : 4868) #pragma warning(disable : 5105) +#pragma warning(disable : 5262) +#pragma warning(disable : 5264) #endif #if !defined(USE_VENDORED_LIBS) || USE_VENDORED_LIBS diff --git a/tests/main.cpp b/tests/main.cpp index 4330d5a..a56fad1 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -3,6 +3,11 @@ // See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text. // SPDX-License-Identifier: MIT +#ifdef _MSC_VER +#pragma warning(disable : 5262) +#pragma warning(disable : 5264) +#endif + #define CATCH_CONFIG_RUNNER #include "lib_catch2.h" #include diff --git a/toml.hpp b/toml.hpp index 7174941..c67e3f9 100644 --- a/toml.hpp +++ b/toml.hpp @@ -494,6 +494,7 @@ __pragma(warning(disable : 4061)) \ __pragma(warning(disable : 4062)) \ __pragma(warning(disable : 4063)) \ + __pragma(warning(disable : 5262)) /* switch-case implicit fallthrough (false-positive) */ \ __pragma(warning(disable : 26819)) /* cg: unannotated fallthrough */ \ static_assert(true) @@ -505,9 +506,9 @@ __pragma(warning(disable : 4505)) /* unreferenced local function removed */ \ __pragma(warning(disable : 4514)) /* unreferenced inline function has been removed */ \ __pragma(warning(disable : 4582)) /* constructor is not implicitly called */ \ - __pragma(warning(disable : 4623)) /* default constructor was implicitly defined as deleted */ \ - __pragma(warning(disable : 4625)) /* copy constructor was implicitly defined as deleted */ \ - __pragma(warning(disable : 4626)) /* assignment operator was implicitly defined as deleted */ \ + __pragma(warning(disable : 4623)) /* default constructor was implicitly defined as deleted */ \ + __pragma(warning(disable : 4625)) /* copy constructor was implicitly defined as deleted */ \ + __pragma(warning(disable : 4626)) /* assignment operator was implicitly defined as deleted */ \ __pragma(warning(disable : 4710)) /* function not inlined */ \ __pragma(warning(disable : 4711)) /* function selected for automatic expansion */ \ __pragma(warning(disable : 4820)) /* N bytes padding added */ \ @@ -516,6 +517,7 @@ __pragma(warning(disable : 5027)) /* move assignment operator was implicitly defined as deleted */ \ __pragma(warning(disable : 5039)) /* potentially throwing function passed to 'extern "C"' function */ \ __pragma(warning(disable : 5045)) /* Compiler will insert Spectre mitigation */ \ + __pragma(warning(disable : 5264)) /* const variable is not used (false-positive) */ \ __pragma(warning(disable : 26451)) \ __pragma(warning(disable : 26490)) \ __pragma(warning(disable : 26495)) \ @@ -538,6 +540,7 @@ __pragma(warning(disable : 4348)) \ __pragma(warning(disable : 4668)) \ __pragma(warning(disable : 5105)) \ + __pragma(warning(disable : 5264)) \ TOML_DISABLE_CODE_ANALYSIS_WARNINGS; \ TOML_DISABLE_SWITCH_WARNINGS; \ TOML_DISABLE_SPAM_WARNINGS; \