Commit 007a787d by Christian Bruel

Fix #52283 error: case label does not reduce to an integer constant

From-SVN: r186586
parent daa57386
2012-04-19 Manuel López-Ibáñez <manu@gcc.gnu.org>
PR c/52283/37985
* stmt.c (warn_if_unused_value): Skip NOP_EXPR.
* convert.c (convert_to_integer): Don't set TREE_NO_WARNING.
2012-04-19 Richard Guenther <rguenther@suse.de>
PR rtl-optimization/44688
......
......@@ -1692,6 +1692,7 @@ warn_if_unused_value (const_tree exp, location_t locus)
case SAVE_EXPR:
case NON_LVALUE_EXPR:
case NOP_EXPR:
exp = TREE_OPERAND (exp, 0);
goto restart;
......
......@@ -537,7 +537,6 @@ convert_to_integer (tree type, tree expr)
else if (outprec >= inprec)
{
enum tree_code code;
tree tem;
/* If the precision of the EXPR's type is K bits and the
destination mode has more bits, and the sign is changing,
......@@ -555,13 +554,7 @@ convert_to_integer (tree type, tree expr)
else
code = NOP_EXPR;
tem = fold_unary (code, type, expr);
if (tem)
return tem;
tem = build1 (code, type, expr);
TREE_NO_WARNING (tem) = 1;
return tem;
return fold_build1 (code, type, expr);
}
/* If TYPE is an enumeral type or a type with a precision less
......
2012-04-19 Christian Bruel <christian.bruel@st.com>
* gcc.dg/pr52283.c: New test.
2012-04-19 Manuel López-Ibáñez <manu@gcc.gnu.org>
* gcc.dg/pr37985.c: New test.
2012-04-19 Richard Guenther <rguenther@suse.de>
PR rtl-optimization/44688
......
/* PR c37985 */
/* { dg-do compile } */
/* { dg-options " -Wall -Wextra " } */
unsigned char foo(unsigned char a)
{
a >> 2; /* { dg-warning "no effect" } */
return a;
}
/* Test for case labels not integer constant expressions but folding
to integer constants (used in Linux kernel). */
/* { dg-do compile } */
extern unsigned int u;
void
b (int c)
{
switch (c)
{
case (int) (2 | ((4 < 8) ? 8 : u)):
;
}
}
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