diff options
| author | David Robillard <d@drobilla.net> | 2022-07-01 12:57:56 -0400 |
|---|---|---|
| committer | Eli Schwartz <eschwartz93@gmail.com> | 2022-11-27 16:50:48 -0500 |
| commit | 81d7c24a59bf4a991fe57579aa11a32b32779680 (patch) | |
| tree | 4f294ec479ddb90506d4ef84bdb8d4d0493641d3 /mesonbuild/compilers | |
| parent | 9751c1fe61c34ea1a9e6a47cae251574586faff5 (diff) | |
| download | meson-81d7c24a59bf4a991fe57579aa11a32b32779680.tar.gz | |
Add warning_level=everything
Adds a new maximum warning level that is roughly equivalent to "all warnings".
This adds a way to use `/Wall` with MSVC (without the previous broken warning),
`-Weverything` with clang, and almost all general warnings in GCC with
strictness roughly equivalent to clang's `-Weverything`.
The GCC case must be implemented by meson since GCC doesn't provide a similar
option. To avoid maintenance headaches for meson, this warning level is
defined objectively: all warnings are included except those that require
specific values or are specific to particular language revisions. This warning
level is mainly intended for new code, and it is expected (nearly guaranteed)
that projects will need to add some suppressions to build cleanly with it.
More commonly, it's just a handy way to occasionally take a look at what
warnings are present with some compiler, in case anything interesting shows up
you might want to enable in general.
Since the warnings enabled at this level are inherently unstable with respect
to compiler versions, it is intended for use by developers and not to be set as
the default.
Diffstat (limited to 'mesonbuild/compilers')
| -rw-r--r-- | mesonbuild/compilers/c.py | 21 | ||||
| -rw-r--r-- | mesonbuild/compilers/cpp.py | 23 | ||||
| -rw-r--r-- | mesonbuild/compilers/d.py | 6 | ||||
| -rw-r--r-- | mesonbuild/compilers/fortran.py | 30 | ||||
| -rw-r--r-- | mesonbuild/compilers/mixins/arm.py | 3 | ||||
| -rw-r--r-- | mesonbuild/compilers/mixins/ccrx.py | 3 | ||||
| -rw-r--r-- | mesonbuild/compilers/mixins/compcert.py | 3 | ||||
| -rw-r--r-- | mesonbuild/compilers/mixins/elbrus.py | 3 | ||||
| -rw-r--r-- | mesonbuild/compilers/mixins/gnu.py | 239 | ||||
| -rw-r--r-- | mesonbuild/compilers/mixins/pgi.py | 3 | ||||
| -rw-r--r-- | mesonbuild/compilers/mixins/ti.py | 3 | ||||
| -rw-r--r-- | mesonbuild/compilers/mixins/visualstudio.py | 1 | ||||
| -rw-r--r-- | mesonbuild/compilers/mixins/xc16.py | 3 | ||||
| -rw-r--r-- | mesonbuild/compilers/objc.py | 10 | ||||
| -rw-r--r-- | mesonbuild/compilers/objcpp.py | 10 |
15 files changed, 321 insertions, 40 deletions
diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py index 0b784420d..51ae246cc 100644 --- a/mesonbuild/compilers/c.py +++ b/mesonbuild/compilers/c.py @@ -28,6 +28,7 @@ from .mixins.ti import TICompiler from .mixins.arm import ArmCompiler, ArmclangCompiler from .mixins.visualstudio import MSVCCompiler, ClangClCompiler from .mixins.gnu import GnuCompiler +from .mixins.gnu import gnu_common_warning_args, gnu_c_warning_args from .mixins.intel import IntelGnuLikeCompiler, IntelVisualStudioLikeCompiler from .mixins.clang import ClangCompiler from .mixins.elbrus import ElbrusCompiler @@ -152,7 +153,8 @@ class ClangCCompiler(_ClangCStds, ClangCompiler, CCompiler): self.warn_args = {'0': [], '1': default_warn_args, '2': default_warn_args + ['-Wextra'], - '3': default_warn_args + ['-Wextra', '-Wpedantic']} + '3': default_warn_args + ['-Wextra', '-Wpedantic'], + 'everything': ['-Weverything']} def get_options(self) -> 'MutableKeyedOptionDictType': opts = super().get_options() @@ -233,7 +235,8 @@ class ArmclangCCompiler(ArmclangCompiler, CCompiler): self.warn_args = {'0': [], '1': default_warn_args, '2': default_warn_args + ['-Wextra'], - '3': default_warn_args + ['-Wextra', '-Wpedantic']} + '3': default_warn_args + ['-Wextra', '-Wpedantic'], + 'everything': ['-Weverything']} def get_options(self) -> 'MutableKeyedOptionDictType': opts = CCompiler.get_options(self) @@ -271,7 +274,10 @@ class GnuCCompiler(GnuCompiler, CCompiler): self.warn_args = {'0': [], '1': default_warn_args, '2': default_warn_args + ['-Wextra'], - '3': default_warn_args + ['-Wextra', '-Wpedantic']} + '3': default_warn_args + ['-Wextra', '-Wpedantic'], + 'everything': (default_warn_args + ['-Wextra', '-Wpedantic'] + + self.supported_warn_args(gnu_common_warning_args) + + self.supported_warn_args(gnu_c_warning_args))} def get_options(self) -> 'MutableKeyedOptionDictType': opts = CCompiler.get_options(self) @@ -385,11 +391,12 @@ class IntelCCompiler(IntelGnuLikeCompiler, CCompiler): info, exe_wrapper, linker=linker, full_version=full_version) IntelGnuLikeCompiler.__init__(self) self.lang_header = 'c-header' - default_warn_args = ['-Wall', '-w3', '-diag-disable:remark'] + default_warn_args = ['-Wall', '-w3'] self.warn_args = {'0': [], - '1': default_warn_args, - '2': default_warn_args + ['-Wextra'], - '3': default_warn_args + ['-Wextra']} + '1': default_warn_args + ['-diag-disable:remark'], + '2': default_warn_args + ['-Wextra', '-diag-disable:remark'], + '3': default_warn_args + ['-Wextra', '-diag-disable:remark'], + 'everything': default_warn_args + ['-Wextra']} def get_options(self) -> 'MutableKeyedOptionDictType': opts = CCompiler.get_options(self) diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py index 1ea9bcae5..7e1cc5432 100644 --- a/mesonbuild/compilers/cpp.py +++ b/mesonbuild/compilers/cpp.py @@ -33,7 +33,7 @@ from .mixins.ccrx import CcrxCompiler from .mixins.ti import TICompiler from .mixins.arm import ArmCompiler, ArmclangCompiler from .mixins.visualstudio import MSVCCompiler, ClangClCompiler -from .mixins.gnu import GnuCompiler +from .mixins.gnu import GnuCompiler, gnu_common_warning_args, gnu_cpp_warning_args from .mixins.intel import IntelGnuLikeCompiler, IntelVisualStudioLikeCompiler from .mixins.clang import ClangCompiler from .mixins.elbrus import ElbrusCompiler @@ -194,7 +194,8 @@ class ClangCPPCompiler(ClangCompiler, CPPCompiler): self.warn_args = {'0': [], '1': default_warn_args, '2': default_warn_args + ['-Wextra'], - '3': default_warn_args + ['-Wextra', '-Wpedantic']} + '3': default_warn_args + ['-Wextra', '-Wpedantic'], + 'everything': ['-Weverything']} def get_options(self) -> 'MutableKeyedOptionDictType': opts = CPPCompiler.get_options(self) @@ -314,7 +315,8 @@ class ArmclangCPPCompiler(ArmclangCompiler, CPPCompiler): self.warn_args = {'0': [], '1': default_warn_args, '2': default_warn_args + ['-Wextra'], - '3': default_warn_args + ['-Wextra', '-Wpedantic']} + '3': default_warn_args + ['-Wextra', '-Wpedantic'], + 'everything': ['-Weverything']} def get_options(self) -> 'MutableKeyedOptionDictType': opts = CPPCompiler.get_options(self) @@ -360,7 +362,10 @@ class GnuCPPCompiler(GnuCompiler, CPPCompiler): self.warn_args = {'0': [], '1': default_warn_args, '2': default_warn_args + ['-Wextra'], - '3': default_warn_args + ['-Wextra', '-Wpedantic']} + '3': default_warn_args + ['-Wextra', '-Wpedantic'], + 'everything': (default_warn_args + ['-Wextra', '-Wpedantic'] + + self.supported_warn_args(gnu_common_warning_args) + + self.supported_warn_args(gnu_cpp_warning_args))} def get_options(self) -> 'MutableKeyedOptionDictType': key = OptionKey('std', machine=self.for_machine, lang=self.language) @@ -535,12 +540,12 @@ class IntelCPPCompiler(IntelGnuLikeCompiler, CPPCompiler): info, exe_wrapper, linker=linker, full_version=full_version) IntelGnuLikeCompiler.__init__(self) self.lang_header = 'c++-header' - default_warn_args = ['-Wall', '-w3', '-diag-disable:remark', - '-Wpch-messages'] + default_warn_args = ['-Wall', '-w3', '-Wpch-messages'] self.warn_args = {'0': [], - '1': default_warn_args, - '2': default_warn_args + ['-Wextra'], - '3': default_warn_args + ['-Wextra']} + '1': default_warn_args + ['-diag-disable:remark'], + '2': default_warn_args + ['-Wextra', '-diag-disable:remark'], + '3': default_warn_args + ['-Wextra', '-diag-disable:remark'], + 'everything': default_warn_args + ['-Wextra']} def get_options(self) -> 'MutableKeyedOptionDictType': opts = CPPCompiler.get_options(self) diff --git a/mesonbuild/compilers/d.py b/mesonbuild/compilers/d.py index b03495c55..c7e3b77ee 100644 --- a/mesonbuild/compilers/d.py +++ b/mesonbuild/compilers/d.py @@ -36,6 +36,7 @@ from .compilers import ( CompileCheckMode, ) from .mixins.gnu import GnuCompiler +from .mixins.gnu import gnu_common_warning_args if T.TYPE_CHECKING: from ..dependencies import Dependency @@ -805,7 +806,10 @@ class GnuDCompiler(GnuCompiler, DCompiler): self.warn_args = {'0': [], '1': default_warn_args, '2': default_warn_args + ['-Wextra'], - '3': default_warn_args + ['-Wextra', '-Wpedantic']} + '3': default_warn_args + ['-Wextra', '-Wpedantic'], + 'everything': (default_warn_args + ['-Wextra', '-Wpedantic'] + + self.supported_warn_args(gnu_common_warning_args))} + self.base_options = { OptionKey(o) for o in [ 'b_colorout', 'b_sanitize', 'b_staticpic', 'b_vscrt', diff --git a/mesonbuild/compilers/fortran.py b/mesonbuild/compilers/fortran.py index 3f388cf34..b82b2ff78 100644 --- a/mesonbuild/compilers/fortran.py +++ b/mesonbuild/compilers/fortran.py @@ -23,7 +23,7 @@ from .compilers import ( ) from .mixins.clike import CLikeCompiler from .mixins.gnu import ( - GnuCompiler, gnulike_buildtype_args, gnu_optimization_args, + GnuCompiler, gnulike_buildtype_args, gnu_optimization_args ) from .mixins.intel import IntelGnuLikeCompiler, IntelVisualStudioLikeCompiler from .mixins.clang import ClangCompiler @@ -155,7 +155,8 @@ class GnuFortranCompiler(GnuCompiler, FortranCompiler): self.warn_args = {'0': [], '1': default_warn_args, '2': default_warn_args + ['-Wextra'], - '3': default_warn_args + ['-Wextra', '-Wpedantic', '-fimplicit-none']} + '3': default_warn_args + ['-Wextra', '-Wpedantic', '-fimplicit-none'], + 'everything': default_warn_args + ['-Wextra', '-Wpedantic', '-fimplicit-none']} def get_options(self) -> 'MutableKeyedOptionDictType': opts = FortranCompiler.get_options(self) @@ -246,7 +247,8 @@ class G95FortranCompiler(FortranCompiler): self.warn_args = {'0': [], '1': default_warn_args, '2': default_warn_args + ['-Wextra'], - '3': default_warn_args + ['-Wextra', '-pedantic']} + '3': default_warn_args + ['-Wextra', '-pedantic'], + 'everything': default_warn_args + ['-Wextra', '-pedantic']} def get_module_outdir_args(self, path: str) -> T.List[str]: return ['-fmod=' + path] @@ -299,7 +301,8 @@ class IntelFortranCompiler(IntelGnuLikeCompiler, FortranCompiler): self.warn_args = {'0': [], '1': default_warn_args, '2': default_warn_args + ['-warn', 'unused'], - '3': ['-warn', 'all']} + '3': ['-warn', 'all'], + 'everything': ['-warn', 'all']} def get_options(self) -> 'MutableKeyedOptionDictType': opts = FortranCompiler.get_options(self) @@ -351,7 +354,8 @@ class IntelClFortranCompiler(IntelVisualStudioLikeCompiler, FortranCompiler): self.warn_args = {'0': [], '1': default_warn_args, '2': default_warn_args + ['/warn:unused'], - '3': ['/warn:all']} + '3': ['/warn:all'], + 'everything': ['/warn:all']} def get_options(self) -> 'MutableKeyedOptionDictType': opts = FortranCompiler.get_options(self) @@ -391,7 +395,8 @@ class PathScaleFortranCompiler(FortranCompiler): self.warn_args = {'0': [], '1': default_warn_args, '2': default_warn_args, - '3': default_warn_args} + '3': default_warn_args, + 'everything': default_warn_args} def openmp_flags(self) -> T.List[str]: return ['-mp'] @@ -412,7 +417,8 @@ class PGIFortranCompiler(PGICompiler, FortranCompiler): self.warn_args = {'0': [], '1': default_warn_args, '2': default_warn_args, - '3': default_warn_args + ['-Mdclchk']} + '3': default_warn_args + ['-Mdclchk'], + 'everything': default_warn_args + ['-Mdclchk']} def language_stdlib_only_link_flags(self, env: 'Environment') -> T.List[str]: # TODO: needs default search path added @@ -437,7 +443,8 @@ class NvidiaHPC_FortranCompiler(PGICompiler, FortranCompiler): self.warn_args = {'0': [], '1': default_warn_args, '2': default_warn_args, - '3': default_warn_args + ['-Mdclchk']} + '3': default_warn_args + ['-Mdclchk'], + 'everything': default_warn_args + ['-Mdclchk']} class FlangFortranCompiler(ClangCompiler, FortranCompiler): @@ -456,7 +463,8 @@ class FlangFortranCompiler(ClangCompiler, FortranCompiler): self.warn_args = {'0': [], '1': default_warn_args, '2': default_warn_args, - '3': default_warn_args} + '3': default_warn_args, + 'everything': default_warn_args} def language_stdlib_only_link_flags(self, env: 'Environment') -> T.List[str]: # We need to apply the search prefix here, as these link arguments may @@ -488,7 +496,8 @@ class Open64FortranCompiler(FortranCompiler): self.warn_args = {'0': [], '1': default_warn_args, '2': default_warn_args, - '3': default_warn_args} + '3': default_warn_args, + 'everything': default_warn_args} def openmp_flags(self) -> T.List[str]: return ['-mp'] @@ -511,6 +520,7 @@ class NAGFortranCompiler(FortranCompiler): '1': [], '2': [], '3': [], + 'everything': [], } def get_always_args(self) -> T.List[str]: diff --git a/mesonbuild/compilers/mixins/arm.py b/mesonbuild/compilers/mixins/arm.py index b3abd70d6..f0cbf592c 100644 --- a/mesonbuild/compilers/mixins/arm.py +++ b/mesonbuild/compilers/mixins/arm.py @@ -85,7 +85,8 @@ class ArmCompiler(Compiler): self.warn_args = {'0': [], '1': default_warn_args, '2': default_warn_args + [], - '3': default_warn_args + []} # type: T.Dict[str, T.List[str]] + '3': default_warn_args + [], + 'everything': default_warn_args + []} # type: T.Dict[str, T.List[str]] # Assembly self.can_compile_suffixes.add('s') diff --git a/mesonbuild/compilers/mixins/ccrx.py b/mesonbuild/compilers/mixins/ccrx.py index f4c5e06c2..1c222140c 100644 --- a/mesonbuild/compilers/mixins/ccrx.py +++ b/mesonbuild/compilers/mixins/ccrx.py @@ -72,7 +72,8 @@ class CcrxCompiler(Compiler): self.warn_args = {'0': [], '1': default_warn_args, '2': default_warn_args + [], - '3': default_warn_args + []} # type: T.Dict[str, T.List[str]] + '3': default_warn_args + [], + 'everything': default_warn_args + []} # type: T.Dict[str, T.List[str]] def get_pic_args(self) -> T.List[str]: # PIC support is not enabled by default for CCRX, diff --git a/mesonbuild/compilers/mixins/compcert.py b/mesonbuild/compilers/mixins/compcert.py index f4f4cdb0e..a0394a9b8 100644 --- a/mesonbuild/compilers/mixins/compcert.py +++ b/mesonbuild/compilers/mixins/compcert.py @@ -72,7 +72,8 @@ class CompCertCompiler(Compiler): self.warn_args = {'0': [], '1': default_warn_args, '2': default_warn_args + [], - '3': default_warn_args + []} # type: T.Dict[str, T.List[str]] + '3': default_warn_args + [], + 'everything': default_warn_args + []} # type: T.Dict[str, T.List[str]] def get_always_args(self) -> T.List[str]: return [] diff --git a/mesonbuild/compilers/mixins/elbrus.py b/mesonbuild/compilers/mixins/elbrus.py index 4cab777c0..736203988 100644 --- a/mesonbuild/compilers/mixins/elbrus.py +++ b/mesonbuild/compilers/mixins/elbrus.py @@ -41,7 +41,8 @@ class ElbrusCompiler(GnuLikeCompiler): self.warn_args = {'0': [], '1': default_warn_args, '2': default_warn_args + ['-Wextra'], - '3': default_warn_args + ['-Wextra', '-Wpedantic']} + '3': default_warn_args + ['-Wextra', '-Wpedantic'], + 'everything': default_warn_args + ['-Wextra', '-Wpedantic']} # FIXME: use _build_wrapper to call this so that linker flags from the env # get applied diff --git a/mesonbuild/compilers/mixins/gnu.py b/mesonbuild/compilers/mixins/gnu.py index 552c5597b..8152b2538 100644 --- a/mesonbuild/compilers/mixins/gnu.py +++ b/mesonbuild/compilers/mixins/gnu.py @@ -92,6 +92,238 @@ gnu_color_args = { 'never': ['-fdiagnostics-color=never'], } # type: T.Dict[str, T.List[str]] +# Warnings collected from the GCC source and documentation. This is an +# objective set of all the warnings flags that apply to general projects: the +# only ones omitted are those that require a project-specific value, or are +# related to non-standard or legacy language support. This behaves roughly +# like -Weverything in clang. Warnings implied by -Wall, -Wextra, or +# higher-level warnings already enabled here are not included in these lists to +# keep them as short as possible. History goes back to GCC 3.0.0, everything +# earlier is considered historical and listed under version 0.0.0. + +# GCC warnings for all C-family languages +# Omitted non-general warnings: +# -Wabi= +# -Waggregate-return +# -Walloc-size-larger-than=BYTES +# -Walloca-larger-than=BYTES +# -Wframe-larger-than=BYTES +# -Wlarger-than=BYTES +# -Wstack-usage=BYTES +# -Wsystem-headers +# -Wtrampolines +# -Wvla-larger-than=BYTES +# +# Omitted warnings enabled elsewhere in meson: +# -Winvalid-pch (GCC 3.4.0) +gnu_common_warning_args = { + "0.0.0": [ + "-Wcast-qual", + "-Wconversion", + "-Wfloat-equal", + "-Wformat=2", + "-Winline", + "-Wmissing-declarations", + "-Wredundant-decls", + "-Wshadow", + "-Wundef", + "-Wuninitialized", + "-Wwrite-strings", + ], + "3.0.0": [ + "-Wdisabled-optimization", + "-Wpacked", + "-Wpadded", + ], + "3.3.0": [ + "-Wmultichar", + "-Wswitch-default", + "-Wswitch-enum", + "-Wunused-macros", + ], + "4.0.0": [ + "-Wmissing-include-dirs", + ], + "4.1.0": [ + "-Wunsafe-loop-optimizations", + "-Wstack-protector", + ], + "4.2.0": [ + "-Wstrict-overflow=5", + ], + "4.3.0": [ + "-Warray-bounds=2", + "-Wlogical-op", + "-Wstrict-aliasing=3", + "-Wvla", + ], + "4.6.0": [ + "-Wdouble-promotion", + "-Wsuggest-attribute=const", + "-Wsuggest-attribute=noreturn", + "-Wsuggest-attribute=pure", + "-Wtrampolines", + ], + "4.7.0": [ + "-Wvector-operation-performance", + ], + "4.8.0": [ + "-Wsuggest-attribute=format", + ], + "4.9.0": [ + "-Wdate-time", + ], + "5.1.0": [ + "-Wformat-signedness", + "-Wnormalized=nfc", + ], + "6.1.0": [ + "-Wduplicated-cond", + "-Wnull-dereference", + "-Wshift-negative-value", + "-Wshift-overflow=2", + "-Wunused-const-variable=2", + ], + "7.1.0": [ + "-Walloca", + "-Walloc-zero", + "-Wformat-overflow=2", + "-Wformat-truncation=2", + "-Wstringop-overflow=3", + ], + "7.2.0": [ + "-Wduplicated-branches", + ], + "8.1.0": [ + "-Wattribute-alias=2", + "-Wcast-align=strict", + "-Wsuggest-attribute=cold", + "-Wsuggest-attribute=malloc", + ], + "10.1.0": [ + "-Wanalyzer-too-complex", + "-Warith-conversion", + ], + "12.1.0": [ + "-Wbidi-chars=ucn", + "-Wopenacc-parallelism", + "-Wtrivial-auto-var-init", + ], +} # type: T.Dict[str, T.List[str]] + +# GCC warnings for C +# Omitted non-general or legacy warnings: +# -Wc11-c2x-compat +# -Wc90-c99-compat +# -Wc99-c11-compat +# -Wdeclaration-after-statement +# -Wtraditional +# -Wtraditional-conversion +gnu_c_warning_args = { + "0.0.0": [ + "-Wbad-function-cast", + "-Wmissing-prototypes", + "-Wnested-externs", + "-Wstrict-prototypes", + ], + "3.4.0": [ + "-Wold-style-definition", + "-Winit-self", + ], + "4.1.0": [ + "-Wc++-compat", + ], + "4.5.0": [ + "-Wunsuffixed-float-constants", + ], +} # type: T.Dict[str, T.List[str]] + +# GCC warnings for C++ +# Omitted non-general or legacy warnings: +# -Wc++0x-compat +# -Wc++1z-compat +# -Wc++2a-compat +# -Wctad-maybe-unsupported +# -Wnamespaces +# -Wtemplates +gnu_cpp_warning_args = { + "0.0.0": [ + "-Wctor-dtor-privacy", + "-Weffc++", + "-Wnon-virtual-dtor", + "-Wold-style-cast", + "-Woverloaded-virtual", + "-Wsign-promo", + ], + "4.0.1": [ + "-Wstrict-null-sentinel", + ], + "4.6.0": [ + "-Wnoexcept", + ], + "4.7.0": [ + "-Wzero-as-null-pointer-constant", + ], + "4.8.0": [ + "-Wabi-tag", + "-Wuseless-cast", + ], + "4.9.0": [ + "-Wconditionally-supported", + ], + "5.1.0": [ + "-Wsuggest-final-methods", + "-Wsuggest-final-types", + "-Wsuggest-override", + ], + "6.1.0": [ + "-Wmultiple-inheritance", + "-Wplacement-new=2", + "-Wvirtual-inheritance", + ], + "7.1.0": [ + "-Waligned-new=all", + "-Wnoexcept-type", + "-Wregister", + ], + "8.1.0": [ + "-Wcatch-value=3", + "-Wextra-semi", + ], + "9.1.0": [ + "-Wdeprecated-copy-dtor", + "-Wredundant-move", + ], + "10.1.0": [ + "-Wcomma-subscript", + "-Wmismatched-tags", + "-Wredundant-tags", + "-Wvolatile", + ], + "11.1.0": [ + "-Wdeprecated-enum-enum-conversion", + "-Wdeprecated-enum-float-conversion", + "-Winvalid-imported-macros", + ], +} # type: T.Dict[str, T.List[str]] + +# GCC warnings for Objective C and Objective C++ +# Omitted non-general or legacy warnings: +# -Wtraditional +# -Wtraditional-conversion +gnu_objc_warning_args = { + "0.0.0": [ + "-Wselector", + ], + "3.3": [ + "-Wundeclared-selector", + ], + "4.1.0": [ + "-Wassign-intercept", + "-Wstrict-selector-match", + ], +} # type: T.Dict[str, T.List[str]] + @functools.lru_cache(maxsize=None) def gnulike_default_include_dirs(compiler: T.Tuple[str, ...], lang: str) -> 'ImmutableListProtocol[str]': @@ -351,6 +583,13 @@ class GnuCompiler(GnuLikeCompiler): args[args.index('-Wpedantic')] = '-pedantic' return args + def supported_warn_args(self, warn_args_by_version: T.Dict[str, T.List[str]]) -> T.List[str]: + result = [] + for version, warn_args in warn_args_by_version.items(): + if mesonlib.version_compare(self.version, '>=' + version): + result += warn_args + return result + def has_builtin_define(self, define: str) -> bool: return define in self.defines diff --git a/mesonbuild/compilers/mixins/pgi.py b/mesonbuild/compilers/mixins/pgi.py index d13e94691..212d130d7 100644 --- a/mesonbuild/compilers/mixins/pgi.py +++ b/mesonbuild/compilers/mixins/pgi.py @@ -53,7 +53,8 @@ class PGICompiler(Compiler): '0': [], '1': default_warn_args, '2': default_warn_args, - '3': default_warn_args + '3': default_warn_args, + 'everything': default_warn_args } def get_module_incdir_args(self) -> T.Tuple[str]: diff --git a/mesonbuild/compilers/mixins/ti.py b/mesonbuild/compilers/mixins/ti.py index 1821b2a82..950c97fe6 100644 --- a/mesonbuild/compilers/mixins/ti.py +++ b/mesonbuild/compilers/mixins/ti.py @@ -71,7 +71,8 @@ class TICompiler(Compiler): self.warn_args = {'0': [], '1': default_warn_args, '2': default_warn_args + [], - '3': default_warn_args + []} # type: T.Dict[str, T.List[str]] + '3': default_warn_args + [], + 'everything': default_warn_args + []} # type: T.Dict[str, T.List[str]] def get_pic_args(self) -> T.List[str]: # PIC support is not enabled by default for TI compilers, diff --git a/mesonbuild/compilers/mixins/visualstudio.py b/mesonbuild/compilers/mixins/visualstudio.py index 76ce9c18b..d61ad42d0 100644 --- a/mesonbuild/compilers/mixins/visualstudio.py +++ b/mesonbuild/compilers/mixins/visualstudio.py @@ -110,6 +110,7 @@ class VisualStudioLikeCompiler(Compiler, metaclass=abc.ABCMeta): '1': ['/W2'], '2': ['/W3'], '3': ['/W4'], + 'everything': ['/Wall'], } # type: T.Dict[str, T.List[str]] INVOKES_LINKER = False diff --git a/mesonbuild/compilers/mixins/xc16.py b/mesonbuild/compilers/mixins/xc16.py index f160b342f..09949a266 100644 --- a/mesonbuild/compilers/mixins/xc16.py +++ b/mesonbuild/compilers/mixins/xc16.py @@ -69,7 +69,8 @@ class Xc16Compiler(Compiler): self.warn_args = {'0': [], '1': default_warn_args, '2': default_warn_args + [], - '3': default_warn_args + []} # type: T.Dict[str, T.List[str]] + '3': default_warn_args + [], + 'everything': default_warn_args + []} # type: T.Dict[str, T.List[str]] def get_always_args(self) -> T.List[str]: return [] diff --git a/mesonbuild/compilers/objc.py b/mesonbuild/compilers/objc.py index fc82e15cf..83dcaadf3 100644 --- a/mesonbuild/compilers/objc.py +++ b/mesonbuild/compilers/objc.py @@ -20,7 +20,7 @@ from ..mesonlib import OptionKey from .compilers import Compiler from .mixins.clike import CLikeCompiler -from .mixins.gnu import GnuCompiler +from .mixins.gnu import GnuCompiler, gnu_common_warning_args, gnu_objc_warning_args from .mixins.clang import ClangCompiler if T.TYPE_CHECKING: @@ -68,7 +68,10 @@ class GnuObjCCompiler(GnuCompiler, ObjCCompiler): self.warn_args = {'0': [], '1': default_warn_args, '2': default_warn_args + ['-Wextra'], - '3': default_warn_args + ['-Wextra', '-Wpedantic']} + '3': default_warn_args + ['-Wextra', '-Wpedantic'], + 'everything': (default_warn_args + ['-Wextra', '-Wpedantic'] + + self.supported_warn_args(gnu_common_warning_args) + + self.supported_warn_args(gnu_objc_warning_args))} class ClangObjCCompiler(ClangCompiler, ObjCCompiler): @@ -85,7 +88,8 @@ class ClangObjCCompiler(ClangCompiler, ObjCCompiler): self.warn_args = {'0': [], '1': default_warn_args, '2': default_warn_args + ['-Wextra'], - '3': default_warn_args + ['-Wextra', '-Wpedantic']} + '3': default_warn_args + ['-Wextra', '-Wpedantic'], + 'everything': ['-Weverything']} def get_options(self) -> 'coredata.MutableKeyedOptionDictType': opts = super().get_options() diff --git a/mesonbuild/compilers/objcpp.py b/mesonbuild/compilers/objcpp.py index f44931fdc..1f9f75635 100644 --- a/mesonbuild/compilers/objcpp.py +++ b/mesonbuild/compilers/objcpp.py @@ -20,7 +20,7 @@ from ..mesonlib import OptionKey from .mixins.clike import CLikeCompiler from .compilers import Compiler -from .mixins.gnu import GnuCompiler +from .mixins.gnu import GnuCompiler, gnu_common_warning_args, gnu_objc_warning_args from .mixins.clang import ClangCompiler if T.TYPE_CHECKING: @@ -67,7 +67,10 @@ class GnuObjCPPCompiler(GnuCompiler, ObjCPPCompiler): self.warn_args = {'0': [], '1': default_warn_args, '2': default_warn_args + ['-Wextra'], - '3': default_warn_args + ['-Wextra', '-Wpedantic']} + '3': default_warn_args + ['-Wextra', '-Wpedantic'], + 'everything': (default_warn_args + ['-Wextra', '-Wpedantic'] + + self.supported_warn_args(gnu_common_warning_args) + + self.supported_warn_args(gnu_objc_warning_args))} class ClangObjCPPCompiler(ClangCompiler, ObjCPPCompiler): @@ -85,7 +88,8 @@ class ClangObjCPPCompiler(ClangCompiler, ObjCPPCompiler): self.warn_args = {'0': [], '1': default_warn_args, '2': default_warn_args + ['-Wextra'], - '3': default_warn_args + ['-Wextra', '-Wpedantic']} + '3': default_warn_args + ['-Wextra', '-Wpedantic'], + 'everything': ['-Weverything']} def get_options(self) -> 'coredata.MutableKeyedOptionDictType': opts = super().get_options() |
