@@ -36,7 +36,10 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang"
36
36
if (WARNINGS_ARE_ERRORS)
37
37
add_compile_options (-Werror)
38
38
endif ()
39
- add_compile_options (-pedantic)
39
+ add_compile_options (-pedantic) # TODO: is this implied by -Weverything?
40
+ endif ()
41
+
42
+ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
40
43
add_compile_options (-Wall)
41
44
add_compile_options (-Wextra)
42
45
add_compile_options (-Wcast-qual) # Cast for removing type qualifiers
@@ -47,7 +50,6 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang"
47
50
add_compile_options (-Wpacked) #
48
51
add_compile_options (-Wredundant-decls) # if anything is declared more than once in the same scope
49
52
add_compile_options (-Wundef)
50
- add_compile_options (-Wno-missing-braces)
51
53
add_compile_options (-Wno-sign-compare)
52
54
add_compile_options (-Wno-multichar)
53
55
add_compile_options (-Woverloaded-virtual) # when a function declaration hides virtual functions from a base class
@@ -58,17 +60,31 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang"
58
60
#add_compile_options(-Wsign-conversion) # too many warnings
59
61
#add_compile_options(-Wunreachable-code) # some GCC versions report lots of warnings
60
62
#add_compile_options(-Wsign-promo)
61
- endif ()
62
63
63
- if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
64
64
# use pipes instead of temporary files - greatly reduces I/O usage
65
65
add_compile_options (-pipe)
66
66
67
- add_compile_options (-Wno-maybe-uninitialized) # there are some false positives
68
67
add_compile_options (-Wsuggest-attribute=noreturn)
69
- add_compile_options (-Wno-shadow) # whenever a local variable or type declaration shadows another one
70
68
add_compile_options_safe(-Wuseless-cast)
71
69
# add_compile_options_safe(-Wsuggest-attribute=returns_nonnull) # reports the warning even if the attribute is set
70
+
71
+ # TODO: evaluate
72
+ #add_compile_options_safe(-Wduplicated-branches)
73
+ #add_compile_options_safe(-Wduplicated-cond)
74
+ #add_compile_options_safe(-Wformat=2)
75
+ #add_compile_options_safe(-Wformat-overflow=2)
76
+ #add_compile_options_safe(-Wformat-signedness)
77
+ #add_compile_options_safe(-Wnull-dereference)
78
+ #add_compile_options_safe(-Wnrvo)
79
+ #add_compile_options_safe(-Wimplicit-fallthrough=5)
80
+ #add_compile_options_safe(-Wmissing-include-dirs)
81
+ #add_compile_options_safe(-Wunused)
82
+ #add_compile_options_safe(-Wunused-const-variable)
83
+ #add_compile_options_safe(-Wuninitialized)
84
+ #add_compile_options_safe(-Wsuggest-attribute=pure)
85
+ #add_compile_options_safe(-Wsuggest-attribute=const)
86
+ #add_compile_options_safe(-Wunused-macros)
87
+ #add_compile_options_safe(-Wpedantic)
72
88
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
73
89
if (CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 14 OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 14)
74
90
# TODO: verify this regression still exists in clang-15
@@ -104,11 +120,10 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
104
120
add_compile_options_safe(-Wno-implicit-float-conversion)
105
121
add_compile_options_safe(-Wno-switch-enum)
106
122
add_compile_options_safe(-Wno-float-conversion)
107
- add_compile_options_safe(-Wno-enum-enum-conversion)
108
123
add_compile_options_safe(-Wno-date-time)
109
124
add_compile_options (-Wno-disabled-macro-expansion)
110
125
add_compile_options_safe(-Wno-bitwise-instead-of-logical)
111
- add_compile_options_safe (-Wno-switch-default )
126
+ add_compile_options (-Wno-sign-compare )
112
127
113
128
# these cannot be fixed properly without adopting later C++ standards
114
129
add_compile_options_safe(-Wno-unsafe-buffer-usage)
@@ -125,9 +140,13 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
125
140
# only needs to be addressed to work around issues in older compilers
126
141
add_compile_options_safe(-Wno-return-std-move-in-c++11)
127
142
143
+ # this is reported even when it is unnecessary i.e. -Wswitch-enum warnings have been mitigated
144
+ add_compile_options_safe(-Wno-switch-default)
145
+
128
146
# warnings we are currently not interested in
129
147
add_compile_options (-Wno-four-char-constants)
130
148
add_compile_options (-Wno-weak-vtables)
149
+ add_compile_options (-Wno-multichar)
131
150
132
151
if (ENABLE_COVERAGE OR ENABLE_COVERAGE_XML)
133
152
message (FATAL_ERROR "Do not use clang to generate code coverage. Use GCC instead." )
0 commit comments