summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/compilers/mixins/clike.py6
-rw-r--r--test cases/common/104 has arg/meson.build6
2 files changed, 10 insertions, 2 deletions
diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py
index 1fddb0f95..9f5fc5052 100644
--- a/mesonbuild/compilers/mixins/clike.py
+++ b/mesonbuild/compilers/mixins/clike.py
@@ -1268,8 +1268,10 @@ class CLikeCompiler(Compiler):
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-'):
+ # check the equivalent enable flag too "-Wforgotten-towel".
+ # Make an exception for -Wno-attributes=x as -Wattributes=x is invalid
+ # for GCC at least.
+ if arg.startswith('-Wno-') and not arg.startswith('-Wno-attributes='):
new_args.append('-W' + arg[5:])
if arg.startswith('-Wl,'):
mlog.warning(f'{arg} looks like a linker argument, '
diff --git a/test cases/common/104 has arg/meson.build b/test cases/common/104 has arg/meson.build
index ba0731111..c85ec9f25 100644
--- a/test cases/common/104 has arg/meson.build
+++ b/test cases/common/104 has arg/meson.build
@@ -52,6 +52,12 @@ if cc.get_id() == 'gcc'
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 cpp.get_id() == 'gcc' and cpp.version().version_compare('>=12.1.0')
+ # Handle special -Wno-attributes=foo where -Wattributes=foo is invalid
+ # i.e. our usual -Wno-foo -Wfoo hack doesn't work for -Wattributes=foo.
+ assert(cpp.has_argument('-Wno-attributes=meson::i_do_not_exist'))
+endif
+
if cc.get_id() == 'clang' and cc.version().version_compare('<=4.0.0')
# 4.0.0 does not support -fpeel-loops. Newer versions may.
# Please adjust above version number as new versions of clang are released.