From 2bcc1397d9a3515b9107127ed42719a97f382bd7 Mon Sep 17 00:00:00 2001 From: "Buissart-Dubois, Julien" Date: Wed, 22 Jul 2020 09:47:10 +0200 Subject: [PATCH] Adding warning and fixing related warning on code Adding Wshadow in the list of warnings as it might be useful to debug some hardly debuggable issues Adding Werror in the list of warnings as the project doesn't raise any warning for now, it might be useful to keep it that way Sorting warnings by alphabetetical order Fixing Wshadow warning --- cmake/utils.cmake | 24 +++++++++++++++--------- include/spdlog/fmt/bundled/core.h | 8 ++++---- include/spdlog/fmt/bundled/format.h | 6 +++--- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/cmake/utils.cmake b/cmake/utils.cmake index d56fc27a..fb9bb6ce 100644 --- a/cmake/utils.cmake +++ b/cmake/utils.cmake @@ -29,21 +29,27 @@ endfunction() function(spdlog_enable_warnings target_name) if(SPDLOG_BUILD_WARNINGS) if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - list(APPEND MSVC_OPTIONS "/W3") + list(APPEND WARNING_OPTIONS "/W3") if(MSVC_VERSION GREATER 1900) # Allow non fatal security warnings for msvc 2015 - list(APPEND MSVC_OPTIONS "/WX") + list(APPEND WARNING_OPTIONS "/WX") endif() + elseif(CMAKE_CXX_COMPILER_ID STREQUAL ".*Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + list(APPEND WARNING_OPTIONS + -Wall + -Wconversion + -Werror + -Wextra + -Wfatal-errors + -Wpedantic + -Wshadow + ) endif() target_compile_options( ${target_name} - PRIVATE $<$,$,$>: - -Wall - -Wextra - -Wconversion - -pedantic - -Wfatal-errors> - $<$:${MSVC_OPTIONS}>) + PRIVATE + ${WARNING_OPTIONS} + ) endif() endfunction() diff --git a/include/spdlog/fmt/bundled/core.h b/include/spdlog/fmt/bundled/core.h index 0e0824f5..56902535 100644 --- a/include/spdlog/fmt/bundled/core.h +++ b/include/spdlog/fmt/bundled/core.h @@ -1252,10 +1252,10 @@ class dynamic_arg_list { public: template const T& push(const Arg& arg) { - auto node = std::unique_ptr>(new typed_node(arg)); - auto& value = node->value; - node->next = std::move(head_); - head_ = std::move(node); + auto node_ptr = std::unique_ptr>(new typed_node(arg)); + auto& value = node_ptr->value; + node_ptr->next = std::move(head_); + head_ = std::move(node_ptr); return value; } }; diff --git a/include/spdlog/fmt/bundled/format.h b/include/spdlog/fmt/bundled/format.h index 4e96539f..4dbbf6ca 100644 --- a/include/spdlog/fmt/bundled/format.h +++ b/include/spdlog/fmt/bundled/format.h @@ -3244,9 +3244,9 @@ template <> struct formatter { specs_.precision, specs_.precision_ref, ctx); using range_type = internal::output_range; - internal::basic_writer writer(range_type(ctx.out())); - writer.write_bytes(b.data_, specs_); - return writer.out(); + internal::basic_writer format_writer(range_type(ctx.out())); + format_writer.write_bytes(b.data_, specs_); + return format_writer.out(); } private: