From: Joel Rosdahl Date: Tue, 1 Apr 2025 19:45:05 +0000 (+0200) Subject: chore: Build with -Wextra-semi/-Wextra-semi-stmt and fix issues X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b970e57bb66d21ed38d74ea145c0054454c0d110;p=thirdparty%2Fccache.git chore: Build with -Wextra-semi/-Wextra-semi-stmt and fix issues --- diff --git a/cmake/DevModeWarnings.cmake b/cmake/DevModeWarnings.cmake index f7f1b0c4..cd89b7c9 100644 --- a/cmake/DevModeWarnings.cmake +++ b/cmake/DevModeWarnings.cmake @@ -3,6 +3,7 @@ set( -Wcast-align -Wdouble-promotion -Wextra + -Wextra-semi -Wnon-virtual-dtor -Wnull-dereference -Woverloaded-virtual @@ -33,6 +34,8 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") ) endif() + add_compile_flag_if_supported(CCACHE_COMPILER_WARNINGS "-Wextra-semi-stmt") + # If compiler supports -Wshadow-field-in-constructor, disable only that. # Otherwise disable shadow. add_compile_flag_if_supported_ex( diff --git a/src/ccache/ccache.cpp b/src/ccache/ccache.cpp index 97f296ec..65ed0c7d 100644 --- a/src/ccache/ccache.cpp +++ b/src/ccache/ccache.cpp @@ -1882,7 +1882,7 @@ hash_argument(const Context& ctx, auto p = compopt_prefix_takes_path(args[i]); if (p) { path = *p; - }; + } } if (path) { hash.hash_delimiter("path exists"); diff --git a/src/ccache/core/exceptions.hpp b/src/ccache/core/exceptions.hpp index b67bb153..da0e2880 100644 --- a/src/ccache/core/exceptions.hpp +++ b/src/ccache/core/exceptions.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2019-2024 Joel Rosdahl and other contributors +// Copyright (C) 2019-2025 Joel Rosdahl and other contributors // // See doc/AUTHORS.adoc for a complete list of contributors. // @@ -57,6 +57,7 @@ class Fatal : public ErrorBase if (_result != 0) { \ throw core::Fatal(FMT(#function " failed: {}", strerror(_result))); \ } \ - } + } \ + static_assert(true) /* allow semicolon after macro */ } // namespace core diff --git a/src/ccache/util/lockfile.cpp b/src/ccache/util/lockfile.cpp index 37afa156..69388b96 100644 --- a/src/ccache/util/lockfile.cpp +++ b/src/ccache/util/lockfile.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2020-2024 Joel Rosdahl and other contributors +// Copyright (C) 2020-2025 Joel Rosdahl and other contributors // // See doc/AUTHORS.adoc for a complete list of contributors. // @@ -64,7 +64,7 @@ public: get() { return m_distribution(m_random_engine); - }; + } private: std::random_device m_random_device; diff --git a/src/ccache/util/logging.hpp b/src/ccache/util/logging.hpp index f4a72f41..51cfbb42 100644 --- a/src/ccache/util/logging.hpp +++ b/src/ccache/util/logging.hpp @@ -1,4 +1,4 @@ -// Copyright (C) 2020-2024 Joel Rosdahl and other contributors +// Copyright (C) 2020-2025 Joel Rosdahl and other contributors // // See doc/AUTHORS.adoc for a complete list of contributors. // @@ -42,7 +42,7 @@ // least one placeholder without flushing and with a reused timestamp. `format` // is checked at compile time. #define BULK_LOG(logger_, format_, ...) \ - logger_.log(fmt::format(FMT_STRING(format_), __VA_ARGS__)); + logger_.log(fmt::format(FMT_STRING(format_), __VA_ARGS__)) namespace util::logging { diff --git a/src/ccache/util/string.cpp b/src/ccache/util/string.cpp index b19d3aae..4f63edb4 100644 --- a/src/ccache/util/string.cpp +++ b/src/ccache/util/string.cpp @@ -243,7 +243,7 @@ parse_duration(std::string_view duration) auto value = parse_unsigned(duration.substr(0, duration.length() - 1)); if (!value) { return value; - }; + } return factor * *value; }