On 5/26/2021 1:29 PM, Martin Sebor via Gcc-patches wrote:
The -Wvla-parameter checking of the bounds of VLA parameters in
function redeclarations has a few bugs: a) it scans the string
that encodes the attribute access representation of the VLA
bounds from the end, failing to consider that the string may
be followed by another for a subsequent VLA, b) it fails to
consider that the chain of VLA bounds is stored in the reverse
order of arguments, and c) it tests the result of TREE_CHAIN
rather than TREE_PURPOSE to determine if a VLA bound has been
specified. This can cause false negatives.
The attached change fixes these three problems. It was tested
on x86_64-linux.
Martin
gcc-100719.diff
PR c/100719 - missing -Wvla-parameter on a mismatch in second parameter
gcc/ChangeLog:
* attribs.c (init_attr_rdwr_indices): Use VLA bounds in the expected
order.
(attr_access::vla_bounds): Also handle VLA bounds.
gcc/c-family/ChangeLog:
* c-warn.c (warn_parm_array_mismatch): Check TREE_PURPOSE to test
for element presence.
gcc/testsuite/ChangeLog:
* gcc.dg/Wvla-parameter-10.c: New test.
* gcc.dg/Wvla-parameter-11.c: New test.
OK
jeff