On 2/14/19 4:20 PM, David Malcolm wrote:
On Thu, 2019-02-14 at 17:32 +0100, Jakub Jelinek wrote:
On Thu, Feb 14, 2019 at 11:26:15AM -0500, David Malcolm wrote:
There's an asymmetry in the warning; it's looking for a comparison
of a
LHS expression against an RHS constant 0, spelled as "0".
If we fold_for_warn on the RHS, then that folding introduces a
warning
for expressions that aren't spelled as "0" but can be folded to 0,
e.g., with:
enum { FOO, BAR };
So, shouldn't it be made symmetric? Check if one argument is literal
0
before folding, and only if it is, fold_for_warn the other argument?
Jakub
The reference to symmetry in my earlier email was somewhat
misleading, sorry.
The test happens after a canonicalization of the ordering happens
here, near the top of shorten_compare:
/* If first arg is constant, swap the args (changing operation
so value is preserved), for canonicalization. Don't do this if
the second arg is 0. */
so this already gives us symmetry.
Here's an updated version of the patch which add the fold_for_warn in
a slightly later place, and adds a comment, and some more test cases.
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.
OK for trunk?
OK.
Jason