diff options
author | David Robillard <d@drobilla.net> | 2023-05-03 11:53:40 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-05-03 11:58:03 -0400 |
commit | 83c02756c8f48fc54c6e2cf96edb9245d891396a (patch) | |
tree | f73f3bc081caf7cf6b9efb5082fcf88c2257f6dd /meson | |
parent | 1a2160b236c06275214f36075dc4e8f05d2ecc64 (diff) | |
download | pugl-83c02756c8f48fc54c6e2cf96edb9245d891396a.tar.gz pugl-83c02756c8f48fc54c6e2cf96edb9245d891396a.tar.bz2 pugl-83c02756c8f48fc54c6e2cf96edb9245d891396a.zip |
Replace strict option with new meson warning level
Diffstat (limited to 'meson')
-rw-r--r-- | meson/suppressions/meson.build | 234 | ||||
-rw-r--r-- | meson/warnings/meson.build | 217 |
2 files changed, 147 insertions, 304 deletions
diff --git a/meson/suppressions/meson.build b/meson/suppressions/meson.build index 9365086..5ecb425 100644 --- a/meson/suppressions/meson.build +++ b/meson/suppressions/meson.build @@ -1,11 +1,9 @@ -# Copyright 2020-2022 David Robillard <d@drobilla.net> +# Copyright 2020-2023 David Robillard <d@drobilla.net> # SPDX-License-Identifier: 0BSD OR ISC -# Project-specific warning suppressions. -# -# This should be used in conjunction with the generic "warnings" sibling that -# enables all reasonable warnings for the compiler. It lives here just to keep -# the top-level meson.build more readable. +# Project-specific warning suppressions + +warning_level = get_option('warning_level') ##### # C # @@ -13,60 +11,92 @@ c_suppressions = [] if cc.get_id() == 'clang' - c_suppressions += [ - '-Wno-bad-function-cast', - '-Wno-declaration-after-statement', - '-Wno-padded', - '-Wno-switch-default', - '-Wno-switch-enum', - ] - - if host_machine.system() == 'darwin' + if warning_level == 'everything' c_suppressions += [ - '-Wno-poison-system-directories', + '-Wno-bad-function-cast', + '-Wno-declaration-after-statement', + '-Wno-padded', + '-Wno-switch-default', + '-Wno-switch-enum', ] - elif host_machine.system() == 'windows' + + if not meson.is_cross_build() + c_suppressions += [ + '-Wno-poison-system-directories', + ] + endif + + if host_machine.system() == 'windows' + c_suppressions += [ + '-Wno-deprecated-declarations', + '-Wno-format-nonliteral', + '-Wno-nonportable-system-include-path', + '-Wno-unused-macros', + ] + endif + endif + +elif cc.get_id() == 'gcc' + if warning_level == 'everything' c_suppressions += [ - '-Wno-deprecated-declarations', - '-Wno-format-nonliteral', - '-Wno-nonportable-system-include-path', - '-Wno-unused-macros', + '-Wno-bad-function-cast', + '-Wno-inline', + '-Wno-padded', + '-Wno-suggest-attribute=const', + '-Wno-suggest-attribute=pure', + '-Wno-switch-default', + '-Wno-switch-enum', + '-Wno-unsuffixed-float-constants', ] + + if host_machine.system() == 'windows' + c_suppressions += [ + '-Wno-cast-function-type', + '-Wno-float-equal', + '-Wno-suggest-attribute=format', + ] + endif endif -elif cc.get_id() == 'gcc' - c_suppressions += [ - '-Wno-bad-function-cast', - '-Wno-inline', - '-Wno-padded', - '-Wno-pedantic', - '-Wno-suggest-attribute=const', - '-Wno-suggest-attribute=pure', - '-Wno-switch-default', - '-Wno-switch-enum', - '-Wno-unsuffixed-float-constants', - ] - if host_machine.system() == 'windows' + if warning_level in ['everything', '3'] c_suppressions += [ - '-Wno-cast-function-type', - '-Wno-float-equal', - '-Wno-suggest-attribute=format', + '-Wno-pedantic', ] endif + elif cc.get_id() == 'msvc' c_suppressions += [ - '/wd4061', # enumerator in switch is not explicitly handled - '/wd4090', # different const qualitifers - '/wd4191', # unsafe conversion from type to type - '/wd4514', # unreferenced inline function has been removed - '/wd4706', # assignment within conditional expression - '/wd4710', # function not inlined - '/wd4711', # function selected for automatic inline expansion - '/wd4820', # padding added after construct - '/wd4996', # POSIX name for this item is deprecated - '/wd5045', # will insert Spectre mitigation for memory load - '/wd5246', # subobject initialization should be wrapped in braces + '/experimental:external', + '/external:W0', + '/external:anglebrackets', ] + + if warning_level == 'everything' + c_suppressions += [ + '/wd4061', # enumerator in switch is not explicitly handled + '/wd4090', # different const qualitifers + '/wd4191', # unsafe conversion from type to type + '/wd4514', # unreferenced inline function has been removed + '/wd4710', # function not inlined + '/wd4711', # function selected for automatic inline expansion + '/wd4820', # padding added after construct + '/wd5045', # will insert Spectre mitigation for memory load + '/wd5246', # subobject initialization should be wrapped in braces + ] + endif + + if warning_level in ['everything', '3'] + c_suppressions += [ + '/wd4100', # unreferenced formal parameter + '/wd4706', # assignment within conditional expression + ] + endif + + if warning_level in ['everything', '3', '2'] + c_suppressions += [ + '/wd4996', # POSIX name for this item is deprecated + ] + endif endif add_project_arguments( @@ -82,47 +112,72 @@ if is_variable('cpp') cpp_suppressions = [] if cpp.get_id() == 'clang' - cpp_suppressions += [ - '-Wno-inline', - '-Wno-padded', - ] - - if host_machine.system() == 'darwin' + if warning_level == 'everything' cpp_suppressions += [ - '-Wno-poison-system-directories', + '-Wno-c++98-compat-pedantic', + '-Wno-inline', + '-Wno-padded', + '-Wno-sign-conversion', ] + + if not meson.is_cross_build() + cpp_suppressions += [ + '-Wno-poison-system-directories', + ] + endif endif elif cpp.get_id() == 'gcc' - cpp_suppressions += [ - '-Wno-inline', - '-Wno-padded', - ] - - if host_machine.system() == 'windows' + if warning_level == 'everything' cpp_suppressions += [ - '-Wno-cast-function-type', - '-Wno-suggest-attribute=format', + '-Wno-inline', + '-Wno-padded', ] + + if host_machine.system() == 'windows' + cpp_suppressions += [ + '-Wno-cast-function-type', + '-Wno-suggest-attribute=format', + ] + endif endif elif cpp.get_id() == 'msvc' cpp_suppressions += [ - '/wd4061', # enumerator in switch is not explicitly handled - '/wd4191', # unsafe conversion from type to type - '/wd4514', # unreferenced inline function has been removed - '/wd4625', # copy constructor implicitly deleted - '/wd4626', # copy assignment operator implicitly deleted - '/wd4706', # assignment within conditional expression - '/wd4710', # function not inlined - '/wd4711', # function selected for automatic inline expansion - '/wd4800', # implicit conversion to bool - '/wd4820', # padding added after construct - '/wd5026', # move constructor implicitly deleted - '/wd5027', # move assignment operator implicitly deleted - '/wd5039', # pointer to potentially throwing function passed to C - '/wd5045', # will insert Spectre mitigation for memory load + '/experimental:external', + '/external:W0', + '/external:anglebrackets', ] + + if warning_level == 'everything' + cpp_suppressions += [ + '/wd4061', # enumerator in switch is not explicitly handled + '/wd4191', # unsafe conversion from type to type + '/wd4514', # unreferenced inline function has been removed + '/wd4625', # copy constructor implicitly deleted + '/wd4626', # copy assignment operator implicitly deleted + '/wd4710', # function not inlined + '/wd4711', # function selected for automatic inline expansion + '/wd4800', # implicit conversion to bool + '/wd4820', # padding added after construct + '/wd5026', # move constructor implicitly deleted + '/wd5027', # move assignment operator implicitly deleted + '/wd5039', # pointer to potentially throwing function passed to C + '/wd5045', # will insert Spectre mitigation for memory load + ] + endif + + if warning_level in ['everything', '3'] + cpp_suppressions += [ + '/wd4706', # assignment within conditional expression + ] + endif + + if warning_level in ['everything', '3', '2'] + cpp_suppressions += [ + '/wd4996', # POSIX name for this item is deprecated + ] + endif endif add_project_arguments( @@ -136,15 +191,20 @@ endif ############### if is_variable('objcc') - objc_suppressions = [ - '-Wno-bad-function-cast', - '-Wno-direct-ivar-access', - '-Wno-padded', - '-Wno-pedantic', - '-Wno-poison-system-directories', - ] + if warning_level == 'everything' + objc_suppressions = [ + '-Wno-bad-function-cast', + '-Wno-direct-ivar-access', + '-Wno-objc-messaging-id', + '-Wno-padded', + '-Wno-pedantic', + '-Wno-poison-system-directories', + '-Wno-switch-enum', + '-Wno-undeclared-selector', + ] - objc_suppressions = objcc.get_supported_arguments(objc_suppressions) - add_project_arguments(objc_suppressions, language: ['objc']) - add_project_arguments(objc_suppressions, language: ['objcpp']) + objc_suppressions = objcc.get_supported_arguments(objc_suppressions) + add_project_arguments(objc_suppressions, language: ['objc']) + add_project_arguments(objc_suppressions, language: ['objcpp']) + endif endif diff --git a/meson/warnings/meson.build b/meson/warnings/meson.build deleted file mode 100644 index 094b2e6..0000000 --- a/meson/warnings/meson.build +++ /dev/null @@ -1,217 +0,0 @@ -# Copyright 2020-2022 David Robillard <d@drobilla.net> -# SPDX-License-Identifier: 0BSD OR ISC - -# General code to enable approximately all warnings in GCC 12, clang, and MSVC. -# -# This is trivial for clang and MSVC, but GCC doesn't have an "everything" -# option, so we need to enable everything we want explicitly. Wall is assumed, -# but Wextra is not, for stability. -# -# These are collected from common.opt and c.opt in the GCC source, and manually -# curated with the help of the GCC documentation. Warnings that are -# application-specific, historical, or about compatibility between specific -# language revisions are omitted. The intent here is to have roughly the same -# meaning as clang's Weverything: extremely strict, but general. Specifically -# omitted are: -# -# General: -# -# Wabi= -# Waggregate-return -# Walloc-size-larger-than=BYTES -# Walloca-larger-than=BYTES -# Wframe-larger-than=BYTES -# Wlarger-than=BYTES -# Wstack-usage=BYTES -# Wsystem-headers -# Wtraditional -# Wtraditional-conversion -# Wtrampolines -# Wvla-larger-than=BYTES -# -# Build specific: -# -# Wpoison-system-directories -# -# C Specific: -# -# Wc11-c2x-compat -# Wc90-c99-compat -# Wc99-c11-compat -# Wdeclaration-after-statement -# Wtraditional -# Wtraditional-conversion -# -# C++ Specific: -# -# Wc++0x-compat -# Wc++1z-compat -# Wc++2a-compat -# Wctad-maybe-unsupported -# Wnamespaces -# Wtemplates - -gcc_common_warnings = [ - '-Wextra', - '-Wpedantic', - - '-Walloc-zero', - '-Walloca', - '-Wanalyzer-too-complex', - '-Warith-conversion', - '-Warray-bounds=2', - '-Wattribute-alias=2', - '-Wbidi-chars=ucn', - '-Wcast-align=strict', - '-Wcast-qual', - '-Wconversion', - '-Wdate-time', - '-Wdisabled-optimization', - '-Wdouble-promotion', - '-Wduplicated-branches', - '-Wduplicated-cond', - '-Wfloat-equal', - '-Wformat-overflow=2', - '-Wformat-signedness', - '-Wformat-truncation=2', - '-Wformat=2', - '-Winit-self', - '-Winline', - '-Winvalid-pch', - '-Wlogical-op', - '-Wmissing-declarations', - '-Wmissing-include-dirs', - '-Wmultichar', - '-Wnormalized=nfc', - '-Wnull-dereference', - '-Wopenacc-parallelism', - '-Wpacked', - '-Wpadded', - '-Wredundant-decls', - '-Wshadow', - '-Wshift-negative-value', - '-Wshift-overflow=2', - '-Wstack-protector', - '-Wstrict-aliasing=3', - '-Wstrict-overflow=5', - '-Wstringop-overflow=3', - '-Wsuggest-attribute=cold', - '-Wsuggest-attribute=const', - '-Wsuggest-attribute=format', - '-Wsuggest-attribute=malloc', - '-Wsuggest-attribute=noreturn', - '-Wsuggest-attribute=pure', - '-Wswitch-default', - '-Wswitch-enum', - '-Wtrampolines', - '-Wtrivial-auto-var-init', - '-Wundef', - '-Wuninitialized', - '-Wunsafe-loop-optimizations', - '-Wunused-const-variable=2', - '-Wunused-macros', - '-Wvector-operation-performance', - '-Wvla', - '-Wwrite-strings', -] - -##### -# C # -##### - -if is_variable('cc') and not is_variable('all_c_warnings') - all_c_warnings = [] - - if cc.get_id() == 'clang' - all_c_warnings += ['-Weverything'] - - elif cc.get_id() == 'gcc' - all_c_warnings += gcc_common_warnings + [ - '-Wbad-function-cast', - '-Wc++-compat', - '-Wmissing-prototypes', - '-Wnested-externs', - '-Wold-style-definition', - '-Wstrict-prototypes', - '-Wunsuffixed-float-constants', - ] - - elif cc.get_id() == 'msvc' - all_c_warnings += ['/Wall'] - endif - - all_c_warnings = cc.get_supported_arguments(all_c_warnings) -endif - -####### -# C++ # -####### - -if is_variable('cpp') - all_cpp_warnings = [] - - if cpp.get_id() == 'clang' - all_cpp_warnings += [ - '-Weverything', - '-Wno-c++98-compat', - '-Wno-c++98-compat-pedantic' - ] - - elif cpp.get_id() == 'gcc' - all_cpp_warnings += gcc_common_warnings + [ - '-Wabi-tag', - '-Waligned-new=all', - '-Wcatch-value=3', - '-Wcomma-subscript', - '-Wconditionally-supported', - '-Wctor-dtor-privacy', - '-Wdeprecated-copy-dtor', - '-Wdeprecated-enum-enum-conversion', - '-Wdeprecated-enum-float-conversion', - '-Weffc++', - '-Wextra-semi', - '-Winvalid-imported-macros', - '-Wmismatched-tags', - '-Wmultiple-inheritance', - '-Wnoexcept', - '-Wnoexcept-type', - '-Wnon-virtual-dtor', - '-Wold-style-cast', - '-Woverloaded-virtual', - '-Wplacement-new=2', - '-Wredundant-move', - '-Wredundant-tags', - '-Wregister', - '-Wsign-promo', - '-Wstrict-null-sentinel', - '-Wsuggest-final-methods', - '-Wsuggest-final-types', - '-Wsuggest-override', - '-Wuseless-cast', - '-Wvirtual-inheritance', - '-Wvolatile', - '-Wzero-as-null-pointer-constant', - ] - - elif cpp.get_id() == 'msvc' - all_cpp_warnings += ['/Wall'] - endif - - all_cpp_warnings = cpp.get_supported_arguments(all_cpp_warnings) -endif - -# Set all_objc_warnings for the current Objective C compiler -if is_variable('objcc') - all_objc_warnings = [] - - if objcc.get_id() == 'clang' - all_objc_warnings += ['-Weverything'] - - elif objc.get_id() == 'gcc' - all_objc_warnings += gcc_common_warnings + [ - '-Wno-direct-ivar-access', - ] - endif - - all_objc_warnings = objcc.get_supported_arguments(all_objc_warnings) -endif |