🔧 add more warning flags from GCC 10

This commit is contained in:
Niels Lohmann 2020-05-28 12:53:22 +02:00
parent bb9619ef8b
commit fcda998ee2
No known key found for this signature in database
GPG key ID: 7F3CEA63AE251B69

View file

@ -116,7 +116,7 @@ pedantic_clang:
-Wno-padded \ -Wno-padded \
-Wno-range-loop-analysis \ -Wno-range-loop-analysis \
-Wno-switch-enum -Wno-covered-switch-default \ -Wno-switch-enum -Wno-covered-switch-default \
-Wno-weak-vtables" cmake -S . -B build_pedantic -GNinja -DCMAKE_BUILD_TYPE=Debug -DJSON_MultipleHeaders=ON -Wno-weak-vtables" cmake -S . -B build_pedantic -GNinja -DCMAKE_BUILD_TYPE=Debug -DJSON_MultipleHeaders=ON -DJSON_BuildTests=On
cmake --build build_pedantic cmake --build build_pedantic
# calling GCC with most warnings # calling GCC with most warnings
@ -124,13 +124,33 @@ pedantic_gcc:
rm -fr build_pedantic rm -fr build_pedantic
CXXFLAGS=" \ CXXFLAGS=" \
-std=c++11 \ -std=c++11 \
-Werror \
-Wno-abi-tag \
-Waddress \ -Waddress \
-Waddress-of-packed-member \ -Waddress-of-packed-member \
-Wno-aggregate-return \
-Waggressive-loop-optimizations \ -Waggressive-loop-optimizations \
-Waligned-new=all \ -Waligned-new=all \
-Wall \ -Wall \
-Walloc-zero \ -Walloc-zero \
-Walloca \ -Walloca \
-Wanalyzer-double-fclose \
-Wanalyzer-double-free \
-Wanalyzer-exposure-through-output-file \
-Wanalyzer-file-leak \
-Wanalyzer-free-of-non-heap \
-Wanalyzer-malloc-leak \
-Wanalyzer-null-argument \
-Wanalyzer-null-dereference \
-Wanalyzer-possible-null-argument \
-Wanalyzer-possible-null-dereference \
-Wanalyzer-stale-setjmp-buffer \
-Wanalyzer-tainted-array-index \
-Wanalyzer-too-complex \
-Wanalyzer-unsafe-call-within-signal-handler \
-Wanalyzer-use-after-free \
-Wanalyzer-use-of-pointer-in-stale-stack-frame \
-Warith-conversion \
-Warray-bounds \ -Warray-bounds \
-Warray-bounds=2 \ -Warray-bounds=2 \
-Wattribute-alias=2 \ -Wattribute-alias=2 \
@ -140,8 +160,13 @@ pedantic_gcc:
-Wbool-operation \ -Wbool-operation \
-Wbuiltin-declaration-mismatch \ -Wbuiltin-declaration-mismatch \
-Wbuiltin-macro-redefined \ -Wbuiltin-macro-redefined \
-Wc++11-compat \
-Wc++14-compat \
-Wc++17-compat \
-Wc++20-compat \
-Wcannot-profile \ -Wcannot-profile \
-Wcast-align \ -Wcast-align \
-Wcast-align=strict \
-Wcast-function-type \ -Wcast-function-type \
-Wcast-qual \ -Wcast-qual \
-Wcatch-value=3 \ -Wcatch-value=3 \
@ -149,8 +174,8 @@ pedantic_gcc:
-Wclass-conversion \ -Wclass-conversion \
-Wclass-memaccess \ -Wclass-memaccess \
-Wclobbered \ -Wclobbered \
-Wcomma-subscript \
-Wcomment \ -Wcomment \
-Wcomments \
-Wconditionally-supported \ -Wconditionally-supported \
-Wconversion \ -Wconversion \
-Wconversion-null \ -Wconversion-null \
@ -175,20 +200,20 @@ pedantic_gcc:
-Wendif-labels \ -Wendif-labels \
-Wenum-compare \ -Wenum-compare \
-Wexpansion-to-defined \ -Wexpansion-to-defined \
-Werror \
-Wextra \ -Wextra \
-Wextra-semi \ -Wextra-semi \
-Wfloat-conversion \ -Wfloat-conversion \
-Wformat \ -Wfloat-equal \
-Wformat-contains-nul \ -Wformat -Wformat-contains-nul \
-Wformat-extra-args \ -Wformat -Wformat-extra-args \
-Wformat-nonliteral \ -Wformat -Wformat-nonliteral \
-Wformat -Wformat-security \
-Wformat -Wformat-y2k \
-Wformat -Wformat-zero-length \
-Wformat-diag \
-Wformat-overflow=2 \ -Wformat-overflow=2 \
-Wformat-security \
-Wformat-signedness \ -Wformat-signedness \
-Wformat-truncation=2 \ -Wformat-truncation=2 \
-Wformat-y2k \
-Wformat-zero-length \
-Wformat=2 \ -Wformat=2 \
-Wframe-address \ -Wframe-address \
-Wfree-nonheap-object \ -Wfree-nonheap-object \
@ -197,6 +222,7 @@ pedantic_gcc:
-Wignored-attributes \ -Wignored-attributes \
-Wignored-qualifiers \ -Wignored-qualifiers \
-Wimplicit-fallthrough=5 \ -Wimplicit-fallthrough=5 \
-Winaccessible-base \
-Winherited-variadic-ctor \ -Winherited-variadic-ctor \
-Winit-list-lifetime \ -Winit-list-lifetime \
-Winit-self \ -Winit-self \
@ -209,33 +235,25 @@ pedantic_gcc:
-Wliteral-suffix \ -Wliteral-suffix \
-Wlogical-not-parentheses \ -Wlogical-not-parentheses \
-Wlogical-op \ -Wlogical-op \
-Wno-long-long \
-Wlto-type-mismatch \ -Wlto-type-mismatch \
-Wmain \ -Wmain \
-Wmaybe-uninitialized \ -Wmaybe-uninitialized \
-Wmemset-elt-size \ -Wmemset-elt-size \
-Wmemset-transposed-args \ -Wmemset-transposed-args \
-Wmisleading-indentation \ -Wmisleading-indentation \
-Wmismatched-tags \
-Wmissing-attributes \ -Wmissing-attributes \
-Wmissing-braces \ -Wmissing-braces \
-Wmissing-declarations \ -Wmissing-declarations \
-Wmissing-field-initializers \ -Wmissing-field-initializers \
-Wmissing-format-attribute \
-Wmissing-include-dirs \ -Wmissing-include-dirs \
-Wmissing-noreturn \
-Wmissing-profile \ -Wmissing-profile \
-Wmultichar \ -Wmultichar \
-Wmultiple-inheritance \ -Wmultiple-inheritance \
-Wmultistatement-macros \ -Wmultistatement-macros \
-Wnarrowing \
-Wno-deprecated-declarations \
-Wno-float-equal \
-Wno-long-long \
-Wno-namespaces \ -Wno-namespaces \
-Wno-padded \ -Wnarrowing \
-Wno-switch-enum \
-Wno-system-headers \
-Wno-templates \
-Wno-undef \
-Wno-noexcept \ -Wno-noexcept \
-Wnoexcept-type \ -Wnoexcept-type \
-Wnon-template-friend \ -Wnon-template-friend \
@ -243,7 +261,7 @@ pedantic_gcc:
-Wnonnull \ -Wnonnull \
-Wnonnull-compare \ -Wnonnull-compare \
-Wnonportable-cfstrings \ -Wnonportable-cfstrings \
-Wnormalized \ -Wnormalized=nfkc \
-Wnull-dereference \ -Wnull-dereference \
-Wodr \ -Wodr \
-Wold-style-cast \ -Wold-style-cast \
@ -254,6 +272,7 @@ pedantic_gcc:
-Wpacked \ -Wpacked \
-Wpacked-bitfield-compat \ -Wpacked-bitfield-compat \
-Wpacked-not-aligned \ -Wpacked-not-aligned \
-Wno-padded \
-Wparentheses \ -Wparentheses \
-Wpedantic \ -Wpedantic \
-Wpessimizing-move \ -Wpessimizing-move \
@ -266,6 +285,7 @@ pedantic_gcc:
-Wpsabi \ -Wpsabi \
-Wredundant-decls \ -Wredundant-decls \
-Wredundant-move \ -Wredundant-move \
-Wredundant-tags \
-Wregister \ -Wregister \
-Wreorder \ -Wreorder \
-Wrestrict \ -Wrestrict \
@ -273,11 +293,7 @@ pedantic_gcc:
-Wreturn-type \ -Wreturn-type \
-Wscalar-storage-order \ -Wscalar-storage-order \
-Wsequence-point \ -Wsequence-point \
-Wshadow \
-Wshadow-compatible-local \
-Wshadow-local \
-Wshadow=compatible-local \ -Wshadow=compatible-local \
-Wshadow=global \
-Wshadow=local \ -Wshadow=local \
-Wshift-count-negative \ -Wshift-count-negative \
-Wshift-count-overflow \ -Wshift-count-overflow \
@ -291,9 +307,13 @@ pedantic_gcc:
-Wsizeof-pointer-div \ -Wsizeof-pointer-div \
-Wsizeof-pointer-memaccess \ -Wsizeof-pointer-memaccess \
-Wstack-protector \ -Wstack-protector \
-Wstrict-aliasing \
-Wstrict-aliasing=3 \ -Wstrict-aliasing=3 \
-Wstrict-null-sentinel \ -Wstrict-null-sentinel \
-Wstrict-overflow \
-Wstrict-overflow=5 \ -Wstrict-overflow=5 \
-Wstring-compare \
-Wstringop-overflow \
-Wstringop-overflow=4 \ -Wstringop-overflow=4 \
-Wstringop-truncation \ -Wstringop-truncation \
-Wsubobject-linkage \ -Wsubobject-linkage \
@ -309,14 +329,19 @@ pedantic_gcc:
-Wswitch \ -Wswitch \
-Wswitch-bool \ -Wswitch-bool \
-Wswitch-default \ -Wswitch-default \
-Wno-switch-enum \
-Wswitch-outside-range \
-Wswitch-unreachable \ -Wswitch-unreachable \
-Wsync-nand \ -Wsync-nand \
-Wsynth \ -Wsynth \
-Wno-system-headers \
-Wtautological-compare \ -Wtautological-compare \
-Wno-templates \
-Wterminate \ -Wterminate \
-Wtrampolines \ -Wtrampolines \
-Wtrigraphs \ -Wtrigraphs \
-Wtype-limits \ -Wtype-limits \
-Wundef \
-Wuninitialized \ -Wuninitialized \
-Wunknown-pragmas \ -Wunknown-pragmas \
-Wunreachable-code \ -Wunreachable-code \
@ -340,10 +365,12 @@ pedantic_gcc:
-Wvirtual-inheritance \ -Wvirtual-inheritance \
-Wvirtual-move-assign \ -Wvirtual-move-assign \
-Wvla \ -Wvla \
-Wvolatile \
-Wvolatile-register-var \ -Wvolatile-register-var \
-Wwrite-strings \ -Wwrite-strings \
-Wzero-as-null-pointer-constant \ -Wzero-as-null-pointer-constant \
" cmake -S . -B build_pedantic -GNinja -DCMAKE_BUILD_TYPE=Debug -DJSON_MultipleHeaders=ON -Wzero-length-bounds \
" cmake -S . -B build_pedantic -GNinja -DCMAKE_BUILD_TYPE=Debug -DJSON_MultipleHeaders=ON -DJSON_BuildTests=On
cmake --build build_pedantic cmake --build build_pedantic
########################################################################## ##########################################################################
@ -353,7 +380,7 @@ pedantic_gcc:
run_benchmarks: run_benchmarks:
rm -fr build_benchmarks rm -fr build_benchmarks
mkdir build_benchmarks mkdir build_benchmarks
cd build_benchmarks ; cmake ../benchmarks -GNinja -DCMAKE_BUILD_TYPE=Release cd build_benchmarks ; cmake ../benchmarks -GNinja -DCMAKE_BUILD_TYPE=Release -DJSON_BuildTests=On
cd build_benchmarks ; ninja cd build_benchmarks ; ninja
cd build_benchmarks ; ./json_benchmarks cd build_benchmarks ; ./json_benchmarks
@ -430,7 +457,7 @@ cppcheck:
clang_analyze: clang_analyze:
rm -fr clang_analyze_build rm -fr clang_analyze_build
mkdir clang_analyze_build mkdir clang_analyze_build
cd clang_analyze_build ; CCC_CXX=$(COMPILER_DIR)/clang++ CXX=$(COMPILER_DIR)/clang++ $(COMPILER_DIR)/scan-build cmake .. -GNinja cd clang_analyze_build ; CCC_CXX=$(COMPILER_DIR)/clang++ CXX=$(COMPILER_DIR)/clang++ $(COMPILER_DIR)/scan-build cmake .. -GNinja -DJSON_BuildTests=On
cd clang_analyze_build ; \ cd clang_analyze_build ; \
$(COMPILER_DIR)/scan-build \ $(COMPILER_DIR)/scan-build \
-enable-checker alpha.core.BoolAssignment,alpha.core.CallAndMessageUnInitRefArg,alpha.core.CastSize,alpha.core.CastToStruct,alpha.core.Conversion,alpha.core.DynamicTypeChecker,alpha.core.FixedAddr,alpha.core.PointerArithm,alpha.core.PointerSub,alpha.core.SizeofPtr,alpha.core.StackAddressAsyncEscape,alpha.core.TestAfterDivZero,alpha.deadcode.UnreachableCode,core.builtin.BuiltinFunctions,core.builtin.NoReturnFunctions,core.CallAndMessage,core.DivideZero,core.DynamicTypePropagation,core.NonnilStringConstants,core.NonNullParamChecker,core.NullDereference,core.StackAddressEscape,core.UndefinedBinaryOperatorResult,core.uninitialized.ArraySubscript,core.uninitialized.Assign,core.uninitialized.Branch,core.uninitialized.CapturedBlockVariable,core.uninitialized.UndefReturn,core.VLASize,cplusplus.InnerPointer,cplusplus.Move,cplusplus.NewDelete,cplusplus.NewDeleteLeaks,cplusplus.SelfAssignment,deadcode.DeadStores,nullability.NullableDereferenced,nullability.NullablePassedToNonnull,nullability.NullableReturnedFromNonnull,nullability.NullPassedToNonnull,nullability.NullReturnedFromNonnull \ -enable-checker alpha.core.BoolAssignment,alpha.core.CallAndMessageUnInitRefArg,alpha.core.CastSize,alpha.core.CastToStruct,alpha.core.Conversion,alpha.core.DynamicTypeChecker,alpha.core.FixedAddr,alpha.core.PointerArithm,alpha.core.PointerSub,alpha.core.SizeofPtr,alpha.core.StackAddressAsyncEscape,alpha.core.TestAfterDivZero,alpha.deadcode.UnreachableCode,core.builtin.BuiltinFunctions,core.builtin.NoReturnFunctions,core.CallAndMessage,core.DivideZero,core.DynamicTypePropagation,core.NonnilStringConstants,core.NonNullParamChecker,core.NullDereference,core.StackAddressEscape,core.UndefinedBinaryOperatorResult,core.uninitialized.ArraySubscript,core.uninitialized.Assign,core.uninitialized.Branch,core.uninitialized.CapturedBlockVariable,core.uninitialized.UndefReturn,core.VLASize,cplusplus.InnerPointer,cplusplus.Move,cplusplus.NewDelete,cplusplus.NewDeleteLeaks,cplusplus.SelfAssignment,deadcode.DeadStores,nullability.NullableDereferenced,nullability.NullablePassedToNonnull,nullability.NullableReturnedFromNonnull,nullability.NullPassedToNonnull,nullability.NullReturnedFromNonnull \
@ -472,7 +499,7 @@ oclint:
clang_sanitize: clang_sanitize:
rm -fr clang_sanitize_build rm -fr clang_sanitize_build
mkdir clang_sanitize_build mkdir clang_sanitize_build
cd clang_sanitize_build ; CXX=$(COMPILER_DIR)/clang++ cmake .. -DJSON_Sanitizer=On -DJSON_MultipleHeaders=ON -GNinja cd clang_sanitize_build ; CXX=$(COMPILER_DIR)/clang++ cmake .. -DJSON_Sanitizer=On -DJSON_MultipleHeaders=ON -DJSON_BuildTests=On -GNinja
cd clang_sanitize_build ; ninja cd clang_sanitize_build ; ninja
cd clang_sanitize_build ; ctest -j10 cd clang_sanitize_build ; ctest -j10