Skip to content

Commit

Permalink
Use -Wno-unknown-warning to simplify warnings
Browse files Browse the repository at this point in the history
A gcc-specific warning option had been added (-Wsuggest-override).  In
theory this was guarded against being used with clang, but that didn't
work if a compilation database was built with gcc and then used with
e.g. clang-tidy.  In that situation clang would complain about the
unrecognized warning.

The suggested workaround in the DEVELOPER_TOOLING docs was to add
-Wno-unknown-warning-option, a clang option to suppress such warnings.

However, we might as well just add that option always, then we don't
need to make the -Wsuggest-override conditional and the build logic is
simplified.

Technically, gcc has no such option, but gcc doesn't complain about
unrecognized disabled warning options (unless there's another error) so
we get lucky there.  Hopefully that remains true back to our earliest
supported gcc.

This might cause problems for compiling with another compiler e.g. icc,
but the way the Makefile was written, it would have had that problem
anyway, since it was added for any non-clang compiler.
  • Loading branch information
jbytheway committed Jan 8, 2020
1 parent 9ea9f81 commit 2a8c48d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
11 changes: 5 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,11 @@ ELSE()
SET(CATA_WARNINGS
"-Werror -Wall -Wextra \
-Wmissing-declarations \
-Wold-style-cast \
-Woverloaded-virtual \
-Wpedantic")
IF(NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
SET(CATA_WARNINGS "${CATA_WARNINGS} -Wsuggest-override")
ENDIF(NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
-Wold-style-cast \
-Woverloaded-virtual \
-Wsuggest-override \
-Wno-unknown-warning-option \
-Wpedantic")
# Compact the whitespace in the warning string
string(REGEX REPLACE "[\t ]+" " " CATA_WARNINGS "${CATA_WARNINGS}")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CATA_WARNINGS}")
Expand Down
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,9 @@ WARNINGS = \
-Wmissing-declarations \
-Wold-style-cast \
-Woverloaded-virtual \
-Wsuggest-override \
-Wno-unknown-warning-option \
-Wpedantic
ifndef CLANG
WARNINGS += -Wsuggest-override
endif
# Uncomment below to disable warnings
#WARNINGS = -w
DEBUGSYMS = -g
Expand Down
2 changes: 1 addition & 1 deletion doc/DEVELOPER_TOOLING.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ to avoid compiler errors.
python3 <llvm-source-root>/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py \
-clang-tidy-binary=build/tools/clang-tidy-plugin/CataAnalyzerPlugin.exe \
-p=build "\.cpp$" \
-extra-arg=-target -extra-arg=x86_64-pc-windows-gnu -extra-arg=-pthread -extra-arg=-DSDL_DISABLE_ANALYZE_MACROS -extra-arg=-Wno-unknown-warning-option \
-extra-arg=-target -extra-arg=x86_64-pc-windows-gnu -extra-arg=-pthread -extra-arg=-DSDL_DISABLE_ANALYZE_MACROS \
-extra-arg=-isystem -extra-arg=<llvm-source-root>/clang/lib/Headers
```

Expand Down

0 comments on commit 2a8c48d

Please sign in to comment.