Skip to content

Commit 9ba3970

Browse files
authored
aligned GCC warnings with Cppcheck (danmar#434)
1 parent 76df97f commit 9ba3970

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

CMakeLists.txt

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,24 @@ function(add_compile_options_safe FLAG)
1919
endfunction()
2020

2121
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
22-
add_compile_options(-Wall -Wextra -pedantic -Wcast-qual -Wfloat-equal -Wmissing-declarations -Wmissing-format-attribute -Wredundant-decls -Wshadow -Wundef -Wold-style-cast -Wno-multichar)
22+
add_compile_options(-pedantic)
23+
add_compile_options(-Wall)
24+
add_compile_options(-Wextra)
25+
add_compile_options(-Wcast-qual) # Cast for removing type qualifiers
26+
add_compile_options(-Wfloat-equal) # Floating values used in equality comparisons
27+
add_compile_options(-Wmissing-declarations) # If a global function is defined without a previous declaration
28+
add_compile_options(-Wmissing-format-attribute) #
29+
add_compile_options(-Wno-long-long)
30+
add_compile_options(-Wpacked) #
31+
add_compile_options(-Wredundant-decls) # if anything is declared more than once in the same scope
32+
add_compile_options(-Wundef)
33+
add_compile_options(-Wno-missing-braces)
34+
add_compile_options(-Wno-sign-compare)
35+
add_compile_options(-Wno-multichar)
36+
add_compile_options(-Woverloaded-virtual) # when a function declaration hides virtual functions from a base class
37+
38+
add_compile_options(-Wsuggest-attribute=noreturn)
39+
add_compile_options_safe(-Wuseless-cast)
2340
elseif (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
2441
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
2542
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")

test.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,9 @@ static void characterLiteral()
279279

280280
#ifdef __GNUC__
281281
// BEGIN Implementation-specific results
282-
ASSERT_EQUALS(static_cast<int>('AB'), simplecpp::characterLiteralToLL("'AB'"));
283-
ASSERT_EQUALS(static_cast<int>('ABC'), simplecpp::characterLiteralToLL("'ABC'"));
284-
ASSERT_EQUALS(static_cast<int>('ABCD'), simplecpp::characterLiteralToLL("'ABCD'"));
282+
ASSERT_EQUALS('AB', simplecpp::characterLiteralToLL("'AB'"));
283+
ASSERT_EQUALS('ABC', simplecpp::characterLiteralToLL("'ABC'"));
284+
ASSERT_EQUALS('ABCD', simplecpp::characterLiteralToLL("'ABCD'"));
285285
ASSERT_EQUALS('\134t', simplecpp::characterLiteralToLL("'\\134t'")); // cppcheck ticket #7452
286286
// END Implementation-specific results
287287
#endif

0 commit comments

Comments
 (0)