aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2018-04-11 17:07:57 +0530
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2018-04-17 09:55:18 +0000
commit695b8f3a0377d3e2ce78ba8716adc365b18edea1 (patch)
treed301a0871874f1ae913c6c50fe006d2404a773bf
parent162a58b493eb30ccca8179febc4cfbf3fdaf7cb5 (diff)
downloadmeson-695b8f3a0377d3e2ce78ba8716adc365b18edea1.zip
meson-695b8f3a0377d3e2ce78ba8716adc365b18edea1.tar.gz
meson-695b8f3a0377d3e2ce78ba8716adc365b18edea1.tar.bz2
cc.has_multi_arguments: Convert all -Wno args
Also add a test for it.
-rw-r--r--mesonbuild/compilers/c.py12
-rw-r--r--test cases/common/112 has arg/meson.build8
2 files changed, 13 insertions, 7 deletions
diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py
index 7f45ecb..a6bd0af 100644
--- a/mesonbuild/compilers/c.py
+++ b/mesonbuild/compilers/c.py
@@ -840,18 +840,18 @@ class CCompiler(Compiler):
return ['-pthread']
def has_multi_arguments(self, args, env):
- for arg in args:
+ for arg in args[:]:
+ # some compilers, e.g. GCC, don't warn for unsupported warning-disable
+ # flags, so when we are testing a flag like "-Wno-forgotten-towel", also
+ # check the equivalent enable flag too "-Wforgotten-towel"
+ if arg.startswith('-Wno-'):
+ args.append('-W' + arg[5:])
if arg.startswith('-Wl,'):
mlog.warning('''{} looks like a linker argument, but has_argument
and other similar methods only support checking compiler arguments.
Using them to check linker arguments are never supported, and results
are likely to be wrong regardless of the compiler you are using.
'''.format(arg))
- # some compilers, e.g. GCC, don't warn for unsupported warning-disable
- # flags, so when we are testing a flag like "-Wno-forgotten-towel", also
- # check the equivalent enable flag too "-Wforgotten-towel"
- if len(args) == 1 and args[0].startswith('-Wno-'):
- args.append('-W' + args[0][5:])
return self.compiles('int i;\n', env, extra_args=args)
diff --git a/test cases/common/112 has arg/meson.build b/test cases/common/112 has arg/meson.build
index 27290a1..ba07311 100644
--- a/test cases/common/112 has arg/meson.build
+++ b/test cases/common/112 has arg/meson.build
@@ -39,11 +39,17 @@ assert(l2.length() == 0, 'First supported did not return empty array.')
if cc.get_id() == 'gcc'
pre_arg = '-Wformat'
- anti_pre_arg = '-Wno-format'
+ # NOTE: We have special handling for -Wno-foo args because gcc silently
+ # ignores unknown -Wno-foo args unless you pass -Werror, so for this test, we
+ # pass it as two separate arguments.
+ anti_pre_arg = ['-W', 'no-format']
arg = '-Werror=format-security'
assert(not cc.has_multi_arguments([anti_pre_arg, arg]), 'Arg that should be broken is not.')
assert(cc.has_multi_arguments(pre_arg), 'Arg that should have worked does not work.')
assert(cc.has_multi_arguments([pre_arg, arg]), 'Arg that should have worked does not work.')
+ # Test that gcc correctly errors out on unknown -Wno flags
+ assert(not cc.has_argument('-Wno-lol-meson-test-flags'), 'should error out on unknown -Wno args')
+ assert(not cc.has_multi_arguments(['-Wno-pragmas', '-Wno-lol-meson-test-flags']), 'should error out even if some -Wno args are valid')
endif
if cc.get_id() == 'clang' and cc.version().version_compare('<=4.0.0')