On 7/8/21 5:36 PM, Jeff Law wrote:
On 7/1/2021 7:02 PM, Martin Sebor via Gcc-patches wrote:
-Wvla-parameter relies on operand_equal_p() with OEP_LEXICOGRAPHIC
set to compare VLA bounds for equality. But operand_equal_p()
doesn't consider decl names, and so nontrivial expressions that
refer to the same function parameter are considered unequal by
the function, leading to false positives.
The attached fix solves the problem by adding a new flag bit,
OEP_DECL_NAME, to set of flags that control the function. When
the bit is set, the function considers distinct decls with
the same name equal. The caller is responsible for ensuring
that the otherwise distinct decls appear in a context where they
can be assumed to refer to the same entity. The only caller that
sets the flag is the -Wvla-parameter checker.
In addition, the patch strips nops from the VLA bound to avoid
false positives with meaningless casts.
I don't particularly like this, though I don't see a better solution.
Can you add some more info to OEP_DECL_NAME to describe the conditions
where it's useful and how callers can correctly use it?
With that, this is OK.
I updated the comment and pushed r12-2329.
Martin