1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-22 17:35:35 +03:00

meson: apply our -Wno-* options also in c++ calls

We compile some c++ code for tests. We would simply use the default options for
those. When the previous commit raised the default warning level, we started
getting warnings from c++ code. Let's add the most important options to the c++
command, so that we get a compilation without any warnings again.

I don't think it makes sense to add *all* the options that we add for c to the
c++ flags, because testing them takes quite a while, and the c++ compilations
are for small amounts of code, mostly to check that the headers have compatible
syntax.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2019-11-10 12:16:41 +01:00
parent 827ca90986
commit e9f4f5667d

View File

@ -303,7 +303,8 @@ install_tests = get_option('install-tests')
if add_languages('cpp', required : fuzzer_build)
# Used only for tests
cxx_cmd = ' '.join(meson.get_compiler('cpp').cmd_array())
cxx = meson.get_compiler('cpp')
cxx_cmd = ' '.join(cxx.cmd_array())
else
cxx_cmd = ''
endif
@ -323,6 +324,24 @@ elif want_fuzzbuzz
fuzzing_engine = meson.get_compiler('cpp').find_library(get_option('fuzzbuzz-engine'), dirs: get_option('fuzzbuzz-engine-dir'))
endif
# Those generate many false positives, and we do not want to change the code to
# avoid them.
basic_disabled_warnings = [
'-Wno-unused-parameter',
'-Wno-missing-field-initializers',
'-Wno-unused-result',
'-Wno-format-signedness',
]
if get_option('b_ndebug') == 'true'
# With asserts disabled with get a bunch of warnings about variables which
# are used only in the asserts. This is not useful at all, so let's just silence
# those warnings.
basic_disabled_warnings += [
'-Wno-unused-variable',
'-Wno-unused-but-set-variable',
]
endif
possible_cc_flags = [
'-Werror=undef',
'-Wlogical-op',
@ -353,10 +372,6 @@ possible_cc_flags = [
'-Wnested-externs',
# negative arguments are correctly detected starting with meson 0.46.
'-Wno-unused-parameter',
'-Wno-missing-field-initializers',
'-Wno-unused-result',
'-Wno-format-signedness',
'-Wno-error=#warnings', # clang
'-Wno-string-plus-int', # clang
@ -401,16 +416,7 @@ if get_option('buildtype') != 'debug'
possible_link_flags += '-Wl,--gc-sections'
endif
if get_option('b_ndebug') == 'true'
# With asserts disabled with get a bunch of warnings about variables which
# are used only in the asserts. This is not useful at all, so let's just silence
# those warnings.
possible_cc_flags += [
'-Wno-unused-variable',
'-Wno-unused-but-set-variable',
]
endif
add_project_arguments(cc.get_supported_arguments(basic_disabled_warnings), language : 'c')
add_project_arguments(cc.get_supported_arguments(possible_cc_flags), language : 'c')
add_project_link_arguments(cc.get_supported_link_arguments(possible_link_flags), language : 'c')
@ -427,6 +433,10 @@ if cc.compiles('''
add_project_arguments('-Werror=shadow', language : 'c')
endif
if cxx_cmd != ''
add_project_arguments(cxx.get_supported_arguments(basic_disabled_warnings), language : 'cpp')
endif
cpp = ' '.join(cc.cmd_array()) + ' -E'
has_wstringop_truncation = cc.has_argument('-Wstringop-truncation')