2017-01-25 18:46:41 +11:00
|
|
|
###############################################################################
|
|
|
|
if (__nc_warnings)
|
|
|
|
return ()
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
set (__nc_warnings TRUE)
|
|
|
|
|
|
|
|
|
|
|
|
###############################################################################
|
2022-06-15 10:46:52 +10:00
|
|
|
include ("${CMAKE_CURRENT_LIST_DIR}/compile_flag.cmake")
|
2017-01-17 19:20:12 +11:00
|
|
|
|
2017-01-25 18:46:41 +11:00
|
|
|
|
|
|
|
###############################################################################
|
2017-01-17 19:20:12 +11:00
|
|
|
append_compile_flag(-Wall)
|
|
|
|
append_compile_flag(-Wextra)
|
|
|
|
|
2018-12-06 16:09:21 +11:00
|
|
|
append_compile_flag(-Wno-pragmas)
|
|
|
|
|
|
|
|
|
2017-01-17 19:20:12 +11:00
|
|
|
# -------------------------------------------------------------------------
|
|
|
|
# General warnings
|
|
|
|
append_compile_flag(-Wbool-compare)
|
|
|
|
append_compile_flag(-Wcast-align)
|
|
|
|
append_compile_flag(-Wcast-qual)
|
|
|
|
append_compile_flag(-Wdisabled-optimization)
|
|
|
|
append_compile_flag(-Wfloat-conversion)
|
|
|
|
append_compile_flag(-Wfloat-equal)
|
|
|
|
append_compile_flag(-Wno-aggressive-loop-optimizations)
|
2019-02-05 12:35:39 +11:00
|
|
|
#append_compile_flag(-Wnoexcept) # Wow this can be annoying when combined with Werror
|
2017-01-17 19:20:12 +11:00
|
|
|
append_compile_flag(-Wnon-virtual-dtor)
|
2018-03-27 20:17:03 +11:00
|
|
|
append_compile_flag(-Wparentheses) # Wparenthesis detects assignment in conditionals...
|
2017-01-17 19:20:12 +11:00
|
|
|
append_compile_flag(-Wpointer-arith)
|
2018-08-20 16:29:32 +10:00
|
|
|
|
|
|
|
# redundant-decls would be useful, but it specifically clashes with GCC
|
|
|
|
# intrinsics under msys2 where the builtin and headers define them with
|
|
|
|
# different linkages.
|
|
|
|
#append_compile_flag(-Wredundant-decls)
|
|
|
|
|
2017-01-17 19:20:12 +11:00
|
|
|
append_compile_flag(-Wshadow)
|
|
|
|
append_compile_flag(-Wsign-compare)
|
|
|
|
append_compile_flag(-Wsign-promo)
|
|
|
|
append_compile_flag(-Wstrict-aliasing)
|
2019-01-20 17:58:46 +11:00
|
|
|
#append_compile_flag(-Wstrict-overflow)
|
2017-01-17 19:20:12 +11:00
|
|
|
append_compile_flag(-Wtype-limits)
|
|
|
|
append_compile_flag(-Wunused-but-set-variable)
|
|
|
|
append_compile_flag(-Wunused-parameter)
|
|
|
|
append_compile_flag(-Wpessimizing-move)
|
2019-02-05 18:17:01 +11:00
|
|
|
# Don't use -Wswitch-enum, it's the same as -Wswitch but also warns if you use
|
|
|
|
# a default. Just don't use a default if that's something you want to catch.
|
2018-12-06 16:09:21 +11:00
|
|
|
append_compile_flag(-Wswitch)
|
2017-01-17 19:20:12 +11:00
|
|
|
|
2017-05-24 15:16:33 +10:00
|
|
|
# dont use unsafe-loop-optimisations as there are too many false positives
|
|
|
|
# with language primitives like range-for.
|
|
|
|
# append_compile_flag(-Wunsafe-loop-optimizations)
|
|
|
|
|
2017-01-17 19:20:12 +11:00
|
|
|
# gcc-6.1.0 warnings
|
|
|
|
append_compile_flag(-Wshift-negative-value)
|
|
|
|
append_compile_flag(-Wnull-dereference)
|
|
|
|
append_compile_flag(-Wduplicated-cond)
|
|
|
|
|
2017-01-31 20:45:18 +11:00
|
|
|
# useless-cast isn't usable on gcc-6.0 or gcc-6.1 due to spurious warnings
|
2017-01-17 19:20:12 +11:00
|
|
|
# see gcc#70844
|
|
|
|
append_compile_flag(-Wuseless-cast)
|
|
|
|
|
2017-05-12 14:56:20 +10:00
|
|
|
# gcc 7 warnings
|
|
|
|
append_compile_flag(-Wduplicated-branches)
|
|
|
|
append_compile_flag(-Wrestrict)
|
|
|
|
append_compile_flag(-Wregister)
|
|
|
|
append_compile_flag(-Wdangling-else)
|
|
|
|
append_compile_flag(-Walloc-zero)
|
|
|
|
append_compile_flag(-Walloca)
|
|
|
|
append_compile_flag(-Wnonnull)
|
|
|
|
append_compile_flag(-Waligned-new)
|
|
|
|
|
2017-06-13 14:10:31 +10:00
|
|
|
append_compile_flag(-Wno-implicit-fallthrough)
|
|
|
|
|
2017-01-17 19:20:12 +11:00
|
|
|
# clang 3.7.1 warnings
|
|
|
|
append_compile_flag(-Wshorten-64-to-32)
|
|
|
|
append_compile_flag(-Wdeprecated)
|
|
|
|
append_compile_flag(-Wcovered-switch-default)
|
2018-12-06 16:09:21 +11:00
|
|
|
append_compile_flag(-Wcovered-switch-default)
|
2017-01-17 19:20:12 +11:00
|
|
|
|
2018-01-23 18:54:14 +11:00
|
|
|
append_compile_flag(-Wno-gnu-string-literal-operator-template)
|
|
|
|
|
2018-05-05 14:37:58 +10:00
|
|
|
# gcc 8.1
|
|
|
|
|
|
|
|
append_compile_flag(-Wmultistatement-macros)
|
|
|
|
append_compile_flag(-Wcast-align=strict)
|
|
|
|
append_compile_flag(-Wold-style-cast)
|
|
|
|
|
2021-04-09 13:32:43 +10:00
|
|
|
append_compile_flag(-Wmissing-field-initializers)
|
2018-05-05 14:37:58 +10:00
|
|
|
|
2021-04-19 15:09:24 +10:00
|
|
|
# clang 12
|
|
|
|
append_compile_flag(-Wcast-function-type)
|
|
|
|
append_compile_flag(-Wstring-concatenation)
|
|
|
|
append_compile_flag(-Wtautological-unsigned-char-zero-compare)
|
|
|
|
append_compile_flag(-Wtautological-value-range-compare)
|
|
|
|
|
2022-05-03 09:55:29 +10:00
|
|
|
# clang 14
|
|
|
|
append_compile_flag(-Wbitwise-instead-of-logical)
|
|
|
|
append_compile_flag(-Wunaligned-access)
|
|
|
|
append_compile_flag(-Wunreachable-code-fallthrough)
|
|
|
|
|
|
|
|
|
2017-01-17 19:20:12 +11:00
|
|
|
# -------------------------------------------------------------------------
|
|
|
|
# Required extensions
|
|
|
|
#AX_APPEND_COMPILE_FLAGS([-Wgnu-flexible-array-union-member], [], [-Werror])
|
|
|
|
#AX_APPEND_COMPILE_FLAGS([-Wno-c99-extensions], [], [-Werror])
|
|
|
|
#AX_APPEND_COMPILE_FLAGS([-Wno-vla-extension], [], [-Werror])
|
|
|
|
append_compile_flag(-Wno-vla)
|
|
|
|
append_compile_flag(-Wno-multichar)
|
2020-02-17 17:40:49 +11:00
|
|
|
append_compile_flag(-Wno-c99-designator)
|
2017-01-17 19:20:12 +11:00
|
|
|
|
|
|
|
#AS_IF([test "x$ax_cv_cxx_compiler_vendor" != "xgnu"], [
|
|
|
|
# AX_APPEND_COMPILE_FLAGS([-Wno-c99-extensions], [], [-Werror])
|
|
|
|
# AX_APPEND_COMPILE_FLAGS([-Wno-flexible-array-extensions], [], [-Werror])
|
|
|
|
# AX_APPEND_COMPILE_FLAGS([-Wno-gnu-conditional-omitted-operand], [], [-Werror])
|
|
|
|
# AX_APPEND_COMPILE_FLAGS([-Wno-gnu-empty-struct], [], [-Werror])
|
|
|
|
# AX_APPEND_COMPILE_FLAGS([-Wno-gnu-flexible-array-union-member], [], [-Werror])
|
|
|
|
# AX_APPEND_COMPILE_FLAGS([-Wno-gnu-zero-variadic-macro-arguments], [], [-Werror])
|
|
|
|
# AX_APPEND_COMPILE_FLAGS([-Wno-vla-extension], [], [-Werror])
|
|
|
|
# AX_APPEND_COMPILE_FLAGS([-Wno-zero-length-array], [], [-Werror])
|
|
|
|
#])
|
|
|
|
|
|
|
|
# -------------------------------------------------------------------------
|
|
|
|
# Excessive warnings
|
|
|
|
append_compile_flag(-Wno-missing-braces)
|
|
|
|
|
|
|
|
#AS_IF([test "x$ax_cv_cxx_compiler_vendor" != "xgnu"], [
|
|
|
|
# AX_APPEND_COMPILE_FLAGS([-Wno-nested-anon-types], [], [-Werror])
|
|
|
|
# AX_APPEND_COMPILE_FLAGS([-Wno-unused-const-variable], [], [-Werror])
|
|
|
|
#])
|
|
|
|
|
|
|
|
# -------------------------------------------------------------------------
|
|
|
|
option (ADVISORY "enable advisory warnings")
|
|
|
|
|
2021-06-03 13:01:17 +10:00
|
|
|
# Always use suggest-override. It has a low false positive rate and mitigates
|
|
|
|
# a possibly significant error.
|
|
|
|
append_compile_flag(-Wsuggest-override)
|
|
|
|
#append_compile_flag(-Woverloaded-virtual)
|
|
|
|
|
2017-01-17 19:20:12 +11:00
|
|
|
if (ADVISORY)
|
|
|
|
append_compile_flag(-Winline)
|
|
|
|
append_compile_flag(-Wsuggest-final-types)
|
|
|
|
append_compile_flag(-Wsuggest-final-methods)
|
|
|
|
append_compile_flag(-Wweak-vtables)
|
|
|
|
append_compile_flag(-Wpadded)
|
|
|
|
endif()
|
|
|
|
|