diff --git a/CMakeLists.txt b/CMakeLists.txt index c3fcf4ba..672e63bb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,24 @@ function(add_compile_options_safe FLAG) endfunction() if (CMAKE_CXX_COMPILER_ID MATCHES "GNU") - add_compile_options(-Wall -Wextra -pedantic -Wcast-qual -Wfloat-equal -Wmissing-declarations -Wmissing-format-attribute -Wredundant-decls -Wshadow -Wundef -Wold-style-cast -Wno-multichar) + add_compile_options(-pedantic) + add_compile_options(-Wall) + add_compile_options(-Wextra) + add_compile_options(-Wcast-qual) # Cast for removing type qualifiers + add_compile_options(-Wfloat-equal) # Floating values used in equality comparisons + add_compile_options(-Wmissing-declarations) # If a global function is defined without a previous declaration + add_compile_options(-Wmissing-format-attribute) # + add_compile_options(-Wno-long-long) + add_compile_options(-Wpacked) # + add_compile_options(-Wredundant-decls) # if anything is declared more than once in the same scope + add_compile_options(-Wundef) + add_compile_options(-Wno-missing-braces) + add_compile_options(-Wno-sign-compare) + add_compile_options(-Wno-multichar) + add_compile_options(-Woverloaded-virtual) # when a function declaration hides virtual functions from a base class + + add_compile_options(-Wsuggest-attribute=noreturn) + add_compile_options_safe(-Wuseless-cast) elseif (CMAKE_CXX_COMPILER_ID MATCHES "MSVC") add_compile_definitions(_CRT_SECURE_NO_WARNINGS) elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang") diff --git a/test.cpp b/test.cpp index 187b7ec6..86e6ddc8 100644 --- a/test.cpp +++ b/test.cpp @@ -279,9 +279,9 @@ static void characterLiteral() #ifdef __GNUC__ // BEGIN Implementation-specific results - ASSERT_EQUALS(static_cast('AB'), simplecpp::characterLiteralToLL("'AB'")); - ASSERT_EQUALS(static_cast('ABC'), simplecpp::characterLiteralToLL("'ABC'")); - ASSERT_EQUALS(static_cast('ABCD'), simplecpp::characterLiteralToLL("'ABCD'")); + ASSERT_EQUALS('AB', simplecpp::characterLiteralToLL("'AB'")); + ASSERT_EQUALS('ABC', simplecpp::characterLiteralToLL("'ABC'")); + ASSERT_EQUALS('ABCD', simplecpp::characterLiteralToLL("'ABCD'")); ASSERT_EQUALS('\134t', simplecpp::characterLiteralToLL("'\\134t'")); // cppcheck ticket #7452 // END Implementation-specific results #endif