Re: [C PATCH] Don't leak C_MAYBE_CONST_EXPRs into fold() (PR c/68412)

2015-11-19 Thread Joseph Myers
On Thu, 19 Nov 2015, Marek Polacek wrote: > On Wed, Nov 18, 2015 at 09:14:46PM +, Joseph Myers wrote: > > remove_c_maybe_const_expr doesn't seem to be quite what you want. Apart > > from this not being a case covered by the comment on the function, you're > > ignoring the possibility of the

Re: [C PATCH] Don't leak C_MAYBE_CONST_EXPRs into fold() (PR c/68412)

2015-11-19 Thread Marek Polacek
On Wed, Nov 18, 2015 at 09:14:46PM +, Joseph Myers wrote: > remove_c_maybe_const_expr doesn't seem to be quite what you want. Apart > from this not being a case covered by the comment on the function, you're > ignoring the possibility of the side effects in the > C_MAYBE_CONST_EXPR_PRE. So

Re: [C PATCH] Don't leak C_MAYBE_CONST_EXPRs into fold() (PR c/68412)

2015-11-18 Thread Joseph Myers
On Wed, 18 Nov 2015, Marek Polacek wrote: > diff --git gcc/c/c-typeck.c gcc/c/c-typeck.c > index c18c307..48c1a98 100644 > --- gcc/c/c-typeck.c > +++ gcc/c/c-typeck.c > @@ -3512,7 +3512,11 @@ parser_build_binary_op (location_t location, enum > tree_code code, > code1, arg

Re: [C PATCH] Don't leak C_MAYBE_CONST_EXPRs into fold() (PR c/68412)

2015-11-18 Thread Marek Polacek
On Wed, Nov 18, 2015 at 05:24:34PM +0100, Bernd Schmidt wrote: > That seems to change the behaviour of the code though. Most of the code in > warn_tautological_cmp only looks at the unfolded form. Are you sure this is > safe, for example wrt. the from_macro_expansion_at tests or the > CONVERT_EXPR_

Re: [C PATCH] Don't leak C_MAYBE_CONST_EXPRs into fold() (PR c/68412)

2015-11-18 Thread Bernd Schmidt
On 11/18/2015 05:16 PM, Marek Polacek wrote: Actually, no, I think we should do this instead. +++ gcc/c-family/c-common.c @@ -1924,7 +1924,7 @@ warn_tautological_cmp (location_t loc, enum tree_code code, tree lhs, tree rhs) /* We do not warn for constants because they are typical of macro

Re: [C PATCH] Don't leak C_MAYBE_CONST_EXPRs into fold() (PR c/68412)

2015-11-18 Thread Marek Polacek
On Wed, Nov 18, 2015 at 05:03:48PM +0100, Marek Polacek wrote: > Since C++ delayed folding, warn_tautological_cmp needs to fold its arguments. > But sometimes this function gets C_MAYBE_CONST_EXPR from the C FE, and fold() > duly ICEs. > > I was torn if I should just return from warn_tautological_