Commit 66f20604 by Marek Polacek Committed by Marek Polacek

re PR c/60036 (Spurious signedness conversion warning with relational operator)

	PR c/60036
c-family/
	* c-common.c (conversion_warning): Unwrap C_MAYBE_CONST_EXPR and/or
	SAVE_EXPR.
testsuite/
	* gcc.dg/pr60036.c: New test.

From-SVN: r207481
parent 8472fa80
2014-02-04 Marek Polacek <polacek@redhat.com>
PR c/60036
* c-common.c (conversion_warning): Unwrap C_MAYBE_CONST_EXPR and/or
SAVE_EXPR.
2014-02-03 Marc Glisse <marc.glisse@inria.fr>
PR c++/53017
......
......@@ -2714,6 +2714,14 @@ conversion_warning (location_t loc, tree type, tree expr)
if (!warn_conversion && !warn_sign_conversion && !warn_float_conversion)
return;
/* This may happen, because for LHS op= RHS we preevaluate
RHS and create C_MAYBE_CONST_EXPR <SAVE_EXPR <RHS>>, which
means we could no longer see the code of the EXPR. */
if (TREE_CODE (expr) == C_MAYBE_CONST_EXPR)
expr = C_MAYBE_CONST_EXPR_EXPR (expr);
if (TREE_CODE (expr) == SAVE_EXPR)
expr = TREE_OPERAND (expr, 0);
switch (TREE_CODE (expr))
{
case EQ_EXPR:
......
2014-02-04 Marek Polacek <polacek@redhat.com>
PR c/60036
* gcc.dg/pr60036.c: New test.
2014-02-04 Markus Trippelsdorf <markus@trippelsdorf.de>
PR ipa/60058
......
/* PR c/60036 */
/* { dg-do compile } */
/* { dg-options "-Wconversion" } */
extern int fn (void);
void
foo (int i)
{
unsigned int f = 9;
/* Don't warn on these. */
f += fn () || i;
f += fn () && i;
f += ! fn ();
f -= fn () == i;
f |= fn () != i;
f &= fn () < i;
f ^= fn () > i;
f &= fn () <= i;
f ^= fn () >= i;
/* But warn on the following. */
f += fn (); /* { dg-warning "conversion" } */
f += fn () | i; /* { dg-warning "conversion" } */
f += fn () & i; /* { dg-warning "conversion" } */
f += fn () ^ i; /* { dg-warning "conversion" } */
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment