Skip to content

Commit e501a22

Browse files
helehtojpakkane
authored andcommitted
c: add more exceptions to -Wno-*
Commit eca1ac1 (#14252) added support for properly detecting the -Wno-vla-larger-than flag: a value must be specified for its positive form (-Wvla-larger-than=N), or GCC will exit with the error "missing argument to ‘-Walloc-size-larger-than=’". There is a handful of other -Wno-* flags whose positive form act in the same manner, but are not covered here: * -Wno-alloc-size-larger-than (GCC >=7.1.0) * -Wno-alloca-larger-than (GCC >=7.1.0) * -Wno-frame-larger-than (GCC >=4.4.0) * -Wno-stack-usage (GCC >=4.7.0) Add logic to treat these in the same way. Signed-off-by: Henrik Lehtonen <eigengrau@vm86.se>
1 parent 189c27e commit e501a22

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

mesonbuild/compilers/mixins/clike.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,12 +1272,21 @@ def _has_multi_arguments(self, args: T.List[str], env: 'Environment', code: str)
12721272
# check the equivalent enable flag too "-Wforgotten-towel".
12731273
if arg.startswith('-Wno-'):
12741274
# Make an exception for -Wno-attributes=x as -Wattributes=x is invalid
1275-
# for GCC at least. Also, the opposite of -Wno-vla-larger-than is
1276-
# -Wvla-larger-than=N
1275+
# for GCC at least. Also, the positive form of some flags require a
1276+
# value to be specified, i.e. we need to pass -Wfoo=N rather than just
1277+
# -Wfoo.
12771278
if arg.startswith('-Wno-attributes='):
12781279
pass
1279-
elif arg == '-Wno-vla-larger-than':
1280-
new_args.append('-Wvla-larger-than=1000')
1280+
elif arg in {
1281+
'-Wno-alloc-size-larger-than',
1282+
'-Wno-alloca-larger-than',
1283+
'-Wno-frame-larger-than',
1284+
'-Wno-stack-usage',
1285+
'-Wno-vla-larger-than',
1286+
}:
1287+
# Pass an arbitrary value to the enabling flag; since the test program
1288+
# is trivial, it is unlikely to provoke any of these warnings.
1289+
new_args.append('-W' + arg[5:] + '=1000')
12811290
else:
12821291
new_args.append('-W' + arg[5:])
12831292
if arg.startswith('-Wl,'):

test cases/common/104 has arg/meson.build

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,22 @@ if cpp.get_id() == 'gcc' and cpp.version().version_compare('>=12.1.0')
5656
# Handle special -Wno-attributes=foo where -Wattributes=foo is invalid
5757
# i.e. our usual -Wno-foo -Wfoo hack doesn't work for -Wattributes=foo.
5858
assert(cpp.has_argument('-Wno-attributes=meson::i_do_not_exist'))
59-
# Likewise, the positive counterpart to -Wno-vla-larger-than is
60-
# -Wvla-larger-than=N
61-
assert(cpp.has_argument('-Wno-vla-larger-than'))
59+
endif
60+
61+
if cpp.get_id() == 'gcc'
62+
# Handle negative flags whose positive counterparts require a value to be
63+
# specified.
64+
if cpp.version().version_compare('>=4.4.0')
65+
assert(cpp.has_argument('-Wno-frame-larger-than'))
66+
endif
67+
if cpp.version().version_compare('>=4.7.0')
68+
assert(cpp.has_argument('-Wno-stack-usage'))
69+
endif
70+
if cpp.version().version_compare('>=7.1.0')
71+
assert(cpp.has_argument('-Wno-alloc-size-larger-than'))
72+
assert(cpp.has_argument('-Wno-alloca-larger-than'))
73+
assert(cpp.has_argument('-Wno-vla-larger-than'))
74+
endif
6275
endif
6376

6477
if cc.get_id() == 'clang' and cc.version().version_compare('<=4.0.0')

0 commit comments

Comments
 (0)