From ea064da16dce643c314d9aee42b70bd7dfb566c9 Mon Sep 17 00:00:00 2001 From: Mark Gillard Date: Tue, 15 Dec 2020 13:39:58 +0200 Subject: [PATCH] fixed useless cast warning on GCC10 also: - removed 'evil macros' test file - updated github templates --- .github/ISSUE_TEMPLATE/bug_report.md | 16 +++++------ .github/ISSUE_TEMPLATE/feature_request.md | 6 ++--- .github/pull_request_template.md | 17 +++--------- include/toml++/toml_array.h | 2 +- include/toml++/toml_default_formatter.hpp | 7 ++--- include/toml++/toml_preprocessor.h | 1 + meson.build | 1 + python/generate_windows_test_targets.py | 1 - tests/evil_macros.h | 27 ------------------- tests/manipulating_values.cpp | 2 ++ tests/tests.h | 2 -- toml.hpp | 10 +++---- vs/tests/test_debug_x64.vcxproj | 1 - vs/tests/test_debug_x64_cpplatest.vcxproj | 1 - .../test_debug_x64_cpplatest_noexcept.vcxproj | 1 - ...debug_x64_cpplatest_noexcept_unrel.vcxproj | 1 - .../test_debug_x64_cpplatest_unrel.vcxproj | 1 - vs/tests/test_debug_x64_noexcept.vcxproj | 1 - .../test_debug_x64_noexcept_unrel.vcxproj | 1 - vs/tests/test_debug_x64_unrel.vcxproj | 1 - vs/tests/test_debug_x86.vcxproj | 1 - vs/tests/test_debug_x86_cpplatest.vcxproj | 1 - .../test_debug_x86_cpplatest_noexcept.vcxproj | 1 - ...debug_x86_cpplatest_noexcept_unrel.vcxproj | 1 - .../test_debug_x86_cpplatest_unrel.vcxproj | 1 - vs/tests/test_debug_x86_noexcept.vcxproj | 1 - .../test_debug_x86_noexcept_unrel.vcxproj | 1 - vs/tests/test_debug_x86_unrel.vcxproj | 1 - vs/tests/test_release_x64.vcxproj | 1 - vs/tests/test_release_x64_cpplatest.vcxproj | 1 - ...est_release_x64_cpplatest_noexcept.vcxproj | 1 - ...lease_x64_cpplatest_noexcept_unrel.vcxproj | 1 - .../test_release_x64_cpplatest_unrel.vcxproj | 1 - vs/tests/test_release_x64_noexcept.vcxproj | 1 - .../test_release_x64_noexcept_unrel.vcxproj | 1 - vs/tests/test_release_x64_unrel.vcxproj | 1 - vs/tests/test_release_x86.vcxproj | 1 - vs/tests/test_release_x86_cpplatest.vcxproj | 1 - ...est_release_x86_cpplatest_noexcept.vcxproj | 1 - ...lease_x86_cpplatest_noexcept_unrel.vcxproj | 1 - .../test_release_x86_cpplatest_unrel.vcxproj | 1 - vs/tests/test_release_x86_noexcept.vcxproj | 1 - .../test_release_x86_noexcept_unrel.vcxproj | 1 - vs/tests/test_release_x86_unrel.vcxproj | 1 - 44 files changed, 25 insertions(+), 99 deletions(-) delete mode 100644 tests/evil_macros.h diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index c940ecc..50e8ef1 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -8,8 +8,8 @@ assignees: marzer --- @@ -20,12 +20,12 @@ assignees: marzer **toml++ version and/or commit hash:** diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 16f91f5..9e5fd76 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -8,8 +8,8 @@ assignees: marzer --- @@ -19,7 +19,7 @@ assignees: marzer **Is your feature request related to a problem? Please describe.** diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 16999ab..1d269ac 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,7 +1,5 @@ @@ -24,7 +22,7 @@ **Pre-merge checklist** - [ ] I've read [CONTRIBUTING.md] - [ ] I've rebased my changes against the current HEAD of `origin/master` (if necessary) @@ -34,17 +32,8 @@ - [ ] I've rebuilt and run the tests with at least one of: - [ ] Clang 6 or higher - [ ] GCC 7 or higher - - [ ] Visual Studio 2019 -- [ ] I've given myself mad props by adding my name to the list of contributors in [README.md](https://github.com/marzer/tomlplusplus/blob/master/README.md) - - - -**Anything else?** - + - [ ] MSVC 19.20 (Visual Studio 2019) or higher +- [ ] I've added my name to the list of contributors in [README.md](https://github.com/marzer/tomlplusplus/blob/master/README.md) diff --git a/include/toml++/toml_array.h b/include/toml++/toml_array.h index 971296d..386e1c0 100644 --- a/include/toml++/toml_array.h +++ b/include/toml++/toml_array.h @@ -1036,7 +1036,7 @@ TOML_NAMESPACE_START /// \returns An rvalue reference to the array. array&& flatten() && { - return static_cast(static_cast(*this).flatten()); + return static_cast(this->flatten()); } /// \brief Prints the array out to a stream as formatted TOML. diff --git a/include/toml++/toml_default_formatter.hpp b/include/toml++/toml_default_formatter.hpp index d2c4034..e2d14f4 100644 --- a/include/toml++/toml_default_formatter.hpp +++ b/include/toml++/toml_default_formatter.hpp @@ -53,10 +53,7 @@ TOML_IMPL_NAMESPACE_START for (auto c : str) { if TOML_UNLIKELY(c >= '\x00' && c <= '\x1F') - { - const auto& sv = low_character_escape_table[c]; - s.append(reinterpret_cast(sv.data()), sv.length()); - } + s.append(low_character_escape_table[c]); else if TOML_UNLIKELY(c == '\x7F') s.append("\\u007F"sv); else if TOML_UNLIKELY(c == '"') @@ -141,7 +138,7 @@ TOML_IMPL_NAMESPACE_START weight += 1; v *= -1.0; } - return weight + static_cast(log10(static_cast(v))) + 1_sz; + return weight + static_cast(log10(v)) + 1_sz; break; } diff --git a/include/toml++/toml_preprocessor.h b/include/toml++/toml_preprocessor.h index 26b6716..566e98c 100644 --- a/include/toml++/toml_preprocessor.h +++ b/include/toml++/toml_preprocessor.h @@ -168,6 +168,7 @@ _Pragma("GCC diagnostic ignored \"-Wcast-align\"") \ _Pragma("GCC diagnostic ignored \"-Wcomment\"") \ _Pragma("GCC diagnostic ignored \"-Wtype-limits\"") \ + _Pragma("GCC diagnostic ignored \"-Wuseless-cast\"") \ _Pragma("GCC diagnostic ignored \"-Wsuggest-attribute=const\"") \ _Pragma("GCC diagnostic ignored \"-Wsuggest-attribute=pure\"") #define TOML_POP_WARNINGS _Pragma("GCC diagnostic pop") diff --git a/meson.build b/meson.build index 9cc1f83..b7a817b 100644 --- a/meson.build +++ b/meson.build @@ -118,6 +118,7 @@ if is_gcc '-Wunreachable-code', '-Wunused', '-Wunused-parameter', + '-Wuseless-cast', '-Wvariadic-macros', '-Wwrite-strings', '-Wmissing-noreturn', diff --git a/python/generate_windows_test_targets.py b/python/generate_windows_test_targets.py index 3567b32..2cf9675 100644 --- a/python/generate_windows_test_targets.py +++ b/python/generate_windows_test_targets.py @@ -129,7 +129,6 @@ def main(): - diff --git a/tests/evil_macros.h b/tests/evil_macros.h deleted file mode 100644 index 28ebb36..0000000 --- a/tests/evil_macros.h +++ /dev/null @@ -1,27 +0,0 @@ -#pragma once - -// simulate some 'evil' macros to ensure the library is robust against them if they appear in the wild. - -#ifdef _WIN32 - -#ifndef min - #define min(...) THIS_IS_AN_EVIL_MACRO -#endif - -#ifndef max - #define max(...) THIS_IS_AN_EVIL_MACRO -#endif - -#ifndef near - #define near THIS_IS_AN_EVIL_MACRO -#endif - -#ifndef far - #define far THIS_IS_AN_EVIL_MACRO -#endif - -#else - -// ... - -#endif diff --git a/tests/manipulating_values.cpp b/tests/manipulating_values.cpp index 1a9fa35..821db64 100644 --- a/tests/manipulating_values.cpp +++ b/tests/manipulating_values.cpp @@ -11,6 +11,8 @@ TOML_DISABLE_WARNINGS TOML_ENABLE_WARNINGS #endif +TOML_DISABLE_SPAM_WARNINGS + template static constexpr T one = static_cast(1); diff --git a/tests/tests.h b/tests/tests.h index 05a9650..b1d4ee3 100644 --- a/tests/tests.h +++ b/tests/tests.h @@ -10,8 +10,6 @@ #include "tloptional.h" #endif -#include "evil_macros.h" - #if USE_SINGLE_HEADER #include "../toml.hpp" #else diff --git a/toml.hpp b/toml.hpp index 76e588e..a902cb4 100644 --- a/toml.hpp +++ b/toml.hpp @@ -190,6 +190,7 @@ _Pragma("GCC diagnostic ignored \"-Wcast-align\"") \ _Pragma("GCC diagnostic ignored \"-Wcomment\"") \ _Pragma("GCC diagnostic ignored \"-Wtype-limits\"") \ + _Pragma("GCC diagnostic ignored \"-Wuseless-cast\"") \ _Pragma("GCC diagnostic ignored \"-Wsuggest-attribute=const\"") \ _Pragma("GCC diagnostic ignored \"-Wsuggest-attribute=pure\"") #define TOML_POP_WARNINGS _Pragma("GCC diagnostic pop") @@ -3963,7 +3964,7 @@ TOML_NAMESPACE_START array& flatten() &; array&& flatten() && { - return static_cast(static_cast(*this).flatten()); + return static_cast(this->flatten()); } template @@ -8368,10 +8369,7 @@ TOML_IMPL_NAMESPACE_START for (auto c : str) { if TOML_UNLIKELY(c >= '\x00' && c <= '\x1F') - { - const auto& sv = low_character_escape_table[c]; - s.append(reinterpret_cast(sv.data()), sv.length()); - } + s.append(low_character_escape_table[c]); else if TOML_UNLIKELY(c == '\x7F') s.append("\\u007F"sv); else if TOML_UNLIKELY(c == '"') @@ -8456,7 +8454,7 @@ TOML_IMPL_NAMESPACE_START weight += 1; v *= -1.0; } - return weight + static_cast(log10(static_cast(v))) + 1_sz; + return weight + static_cast(log10(v)) + 1_sz; break; } diff --git a/vs/tests/test_debug_x64.vcxproj b/vs/tests/test_debug_x64.vcxproj index 2f401ab..b77042f 100644 --- a/vs/tests/test_debug_x64.vcxproj +++ b/vs/tests/test_debug_x64.vcxproj @@ -86,7 +86,6 @@ - diff --git a/vs/tests/test_debug_x64_cpplatest.vcxproj b/vs/tests/test_debug_x64_cpplatest.vcxproj index bccf936..ab61eff 100644 --- a/vs/tests/test_debug_x64_cpplatest.vcxproj +++ b/vs/tests/test_debug_x64_cpplatest.vcxproj @@ -86,7 +86,6 @@ - diff --git a/vs/tests/test_debug_x64_cpplatest_noexcept.vcxproj b/vs/tests/test_debug_x64_cpplatest_noexcept.vcxproj index 72e753f..8832b36 100644 --- a/vs/tests/test_debug_x64_cpplatest_noexcept.vcxproj +++ b/vs/tests/test_debug_x64_cpplatest_noexcept.vcxproj @@ -86,7 +86,6 @@ - diff --git a/vs/tests/test_debug_x64_cpplatest_noexcept_unrel.vcxproj b/vs/tests/test_debug_x64_cpplatest_noexcept_unrel.vcxproj index ababa99..8b06b95 100644 --- a/vs/tests/test_debug_x64_cpplatest_noexcept_unrel.vcxproj +++ b/vs/tests/test_debug_x64_cpplatest_noexcept_unrel.vcxproj @@ -86,7 +86,6 @@ - diff --git a/vs/tests/test_debug_x64_cpplatest_unrel.vcxproj b/vs/tests/test_debug_x64_cpplatest_unrel.vcxproj index f8e2e31..be56fed 100644 --- a/vs/tests/test_debug_x64_cpplatest_unrel.vcxproj +++ b/vs/tests/test_debug_x64_cpplatest_unrel.vcxproj @@ -86,7 +86,6 @@ - diff --git a/vs/tests/test_debug_x64_noexcept.vcxproj b/vs/tests/test_debug_x64_noexcept.vcxproj index 5264306..dc46033 100644 --- a/vs/tests/test_debug_x64_noexcept.vcxproj +++ b/vs/tests/test_debug_x64_noexcept.vcxproj @@ -86,7 +86,6 @@ - diff --git a/vs/tests/test_debug_x64_noexcept_unrel.vcxproj b/vs/tests/test_debug_x64_noexcept_unrel.vcxproj index d2a0a44..9f5e1eb 100644 --- a/vs/tests/test_debug_x64_noexcept_unrel.vcxproj +++ b/vs/tests/test_debug_x64_noexcept_unrel.vcxproj @@ -86,7 +86,6 @@ - diff --git a/vs/tests/test_debug_x64_unrel.vcxproj b/vs/tests/test_debug_x64_unrel.vcxproj index 57e4b33..c6641a0 100644 --- a/vs/tests/test_debug_x64_unrel.vcxproj +++ b/vs/tests/test_debug_x64_unrel.vcxproj @@ -86,7 +86,6 @@ - diff --git a/vs/tests/test_debug_x86.vcxproj b/vs/tests/test_debug_x86.vcxproj index cbaa435..f256b99 100644 --- a/vs/tests/test_debug_x86.vcxproj +++ b/vs/tests/test_debug_x86.vcxproj @@ -86,7 +86,6 @@ - diff --git a/vs/tests/test_debug_x86_cpplatest.vcxproj b/vs/tests/test_debug_x86_cpplatest.vcxproj index 268b475..d264c74 100644 --- a/vs/tests/test_debug_x86_cpplatest.vcxproj +++ b/vs/tests/test_debug_x86_cpplatest.vcxproj @@ -86,7 +86,6 @@ - diff --git a/vs/tests/test_debug_x86_cpplatest_noexcept.vcxproj b/vs/tests/test_debug_x86_cpplatest_noexcept.vcxproj index 5bdddf7..b22ce6d 100644 --- a/vs/tests/test_debug_x86_cpplatest_noexcept.vcxproj +++ b/vs/tests/test_debug_x86_cpplatest_noexcept.vcxproj @@ -86,7 +86,6 @@ - diff --git a/vs/tests/test_debug_x86_cpplatest_noexcept_unrel.vcxproj b/vs/tests/test_debug_x86_cpplatest_noexcept_unrel.vcxproj index 462a730..f576d40 100644 --- a/vs/tests/test_debug_x86_cpplatest_noexcept_unrel.vcxproj +++ b/vs/tests/test_debug_x86_cpplatest_noexcept_unrel.vcxproj @@ -86,7 +86,6 @@ - diff --git a/vs/tests/test_debug_x86_cpplatest_unrel.vcxproj b/vs/tests/test_debug_x86_cpplatest_unrel.vcxproj index d39d437..03f199e 100644 --- a/vs/tests/test_debug_x86_cpplatest_unrel.vcxproj +++ b/vs/tests/test_debug_x86_cpplatest_unrel.vcxproj @@ -86,7 +86,6 @@ - diff --git a/vs/tests/test_debug_x86_noexcept.vcxproj b/vs/tests/test_debug_x86_noexcept.vcxproj index cb5f3f2..c3beeaf 100644 --- a/vs/tests/test_debug_x86_noexcept.vcxproj +++ b/vs/tests/test_debug_x86_noexcept.vcxproj @@ -86,7 +86,6 @@ - diff --git a/vs/tests/test_debug_x86_noexcept_unrel.vcxproj b/vs/tests/test_debug_x86_noexcept_unrel.vcxproj index 3f558d5..b98df2e 100644 --- a/vs/tests/test_debug_x86_noexcept_unrel.vcxproj +++ b/vs/tests/test_debug_x86_noexcept_unrel.vcxproj @@ -86,7 +86,6 @@ - diff --git a/vs/tests/test_debug_x86_unrel.vcxproj b/vs/tests/test_debug_x86_unrel.vcxproj index 99d8da9..804c4f0 100644 --- a/vs/tests/test_debug_x86_unrel.vcxproj +++ b/vs/tests/test_debug_x86_unrel.vcxproj @@ -86,7 +86,6 @@ - diff --git a/vs/tests/test_release_x64.vcxproj b/vs/tests/test_release_x64.vcxproj index fd2b71f..2eff305 100644 --- a/vs/tests/test_release_x64.vcxproj +++ b/vs/tests/test_release_x64.vcxproj @@ -86,7 +86,6 @@ - diff --git a/vs/tests/test_release_x64_cpplatest.vcxproj b/vs/tests/test_release_x64_cpplatest.vcxproj index a3b3ce5..ef2cbf1 100644 --- a/vs/tests/test_release_x64_cpplatest.vcxproj +++ b/vs/tests/test_release_x64_cpplatest.vcxproj @@ -86,7 +86,6 @@ - diff --git a/vs/tests/test_release_x64_cpplatest_noexcept.vcxproj b/vs/tests/test_release_x64_cpplatest_noexcept.vcxproj index f0ed385..cb08288 100644 --- a/vs/tests/test_release_x64_cpplatest_noexcept.vcxproj +++ b/vs/tests/test_release_x64_cpplatest_noexcept.vcxproj @@ -86,7 +86,6 @@ - diff --git a/vs/tests/test_release_x64_cpplatest_noexcept_unrel.vcxproj b/vs/tests/test_release_x64_cpplatest_noexcept_unrel.vcxproj index 3576acd..adfbc04 100644 --- a/vs/tests/test_release_x64_cpplatest_noexcept_unrel.vcxproj +++ b/vs/tests/test_release_x64_cpplatest_noexcept_unrel.vcxproj @@ -86,7 +86,6 @@ - diff --git a/vs/tests/test_release_x64_cpplatest_unrel.vcxproj b/vs/tests/test_release_x64_cpplatest_unrel.vcxproj index 97d927f..255f556 100644 --- a/vs/tests/test_release_x64_cpplatest_unrel.vcxproj +++ b/vs/tests/test_release_x64_cpplatest_unrel.vcxproj @@ -86,7 +86,6 @@ - diff --git a/vs/tests/test_release_x64_noexcept.vcxproj b/vs/tests/test_release_x64_noexcept.vcxproj index a7a4a31..1f29251 100644 --- a/vs/tests/test_release_x64_noexcept.vcxproj +++ b/vs/tests/test_release_x64_noexcept.vcxproj @@ -86,7 +86,6 @@ - diff --git a/vs/tests/test_release_x64_noexcept_unrel.vcxproj b/vs/tests/test_release_x64_noexcept_unrel.vcxproj index eb0c2ed..6b3757d 100644 --- a/vs/tests/test_release_x64_noexcept_unrel.vcxproj +++ b/vs/tests/test_release_x64_noexcept_unrel.vcxproj @@ -86,7 +86,6 @@ - diff --git a/vs/tests/test_release_x64_unrel.vcxproj b/vs/tests/test_release_x64_unrel.vcxproj index 0d95ae3..588f155 100644 --- a/vs/tests/test_release_x64_unrel.vcxproj +++ b/vs/tests/test_release_x64_unrel.vcxproj @@ -86,7 +86,6 @@ - diff --git a/vs/tests/test_release_x86.vcxproj b/vs/tests/test_release_x86.vcxproj index ce59380..1aa3a2e 100644 --- a/vs/tests/test_release_x86.vcxproj +++ b/vs/tests/test_release_x86.vcxproj @@ -86,7 +86,6 @@ - diff --git a/vs/tests/test_release_x86_cpplatest.vcxproj b/vs/tests/test_release_x86_cpplatest.vcxproj index a5cfbae..a6795d9 100644 --- a/vs/tests/test_release_x86_cpplatest.vcxproj +++ b/vs/tests/test_release_x86_cpplatest.vcxproj @@ -86,7 +86,6 @@ - diff --git a/vs/tests/test_release_x86_cpplatest_noexcept.vcxproj b/vs/tests/test_release_x86_cpplatest_noexcept.vcxproj index b2bd7fd..ec04f23 100644 --- a/vs/tests/test_release_x86_cpplatest_noexcept.vcxproj +++ b/vs/tests/test_release_x86_cpplatest_noexcept.vcxproj @@ -86,7 +86,6 @@ - diff --git a/vs/tests/test_release_x86_cpplatest_noexcept_unrel.vcxproj b/vs/tests/test_release_x86_cpplatest_noexcept_unrel.vcxproj index b42177d..76437c1 100644 --- a/vs/tests/test_release_x86_cpplatest_noexcept_unrel.vcxproj +++ b/vs/tests/test_release_x86_cpplatest_noexcept_unrel.vcxproj @@ -86,7 +86,6 @@ - diff --git a/vs/tests/test_release_x86_cpplatest_unrel.vcxproj b/vs/tests/test_release_x86_cpplatest_unrel.vcxproj index a1ca654..07038b7 100644 --- a/vs/tests/test_release_x86_cpplatest_unrel.vcxproj +++ b/vs/tests/test_release_x86_cpplatest_unrel.vcxproj @@ -86,7 +86,6 @@ - diff --git a/vs/tests/test_release_x86_noexcept.vcxproj b/vs/tests/test_release_x86_noexcept.vcxproj index 074bb22..6fa150a 100644 --- a/vs/tests/test_release_x86_noexcept.vcxproj +++ b/vs/tests/test_release_x86_noexcept.vcxproj @@ -86,7 +86,6 @@ - diff --git a/vs/tests/test_release_x86_noexcept_unrel.vcxproj b/vs/tests/test_release_x86_noexcept_unrel.vcxproj index 672f9cb..a4505b1 100644 --- a/vs/tests/test_release_x86_noexcept_unrel.vcxproj +++ b/vs/tests/test_release_x86_noexcept_unrel.vcxproj @@ -86,7 +86,6 @@ - diff --git a/vs/tests/test_release_x86_unrel.vcxproj b/vs/tests/test_release_x86_unrel.vcxproj index ef61035..476ef64 100644 --- a/vs/tests/test_release_x86_unrel.vcxproj +++ b/vs/tests/test_release_x86_unrel.vcxproj @@ -86,7 +86,6 @@ -