From 6befd6b053f32de162090b6ee6316c6ac5bcaef0 Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Thu, 29 Jul 2010 10:59:54 +0000 Subject: re PR tree-optimization/45034 ("safe" conversion from unsigned to signed char gives broken code) 2010-07-29 Richard Guenther PR middle-end/45034 * convert.c (convert_to_integer): Always use an unsigned type for narrowed negate and bitwise not. * gcc.c-torture/execute/pr45034.c: New testcase. From-SVN: r162673 --- gcc/convert.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'gcc/convert.c') diff --git a/gcc/convert.c b/gcc/convert.c index 48f3f944c71..57eedbf5388 100644 --- a/gcc/convert.c +++ b/gcc/convert.c @@ -799,14 +799,7 @@ convert_to_integer (tree type, tree expr) /* This is not correct for ABS_EXPR, since we must test the sign before truncation. */ { - tree typex; - - /* Don't do unsigned arithmetic where signed was wanted, - or vice versa. */ - if (TYPE_UNSIGNED (TREE_TYPE (expr))) - typex = unsigned_type_for (type); - else - typex = signed_type_for (type); + tree typex = unsigned_type_for (type); return convert (type, fold_build1 (ex_form, typex, convert (typex, -- cgit v1.2.1