summaryrefslogtreecommitdiff
path: root/gcc/convert.c
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2010-07-29 10:59:54 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2010-07-29 10:59:54 +0000
commit6befd6b053f32de162090b6ee6316c6ac5bcaef0 (patch)
tree6a70422b360d8f8cb89bc1cd1f4fee1cfffc246a /gcc/convert.c
parent6cfcf3eda65ef5ea3f3a5f3e16bb89b48cef1dce (diff)
downloadgcc-6befd6b053f32de162090b6ee6316c6ac5bcaef0.tar.gz
re PR tree-optimization/45034 ("safe" conversion from unsigned to signed char gives broken code)
2010-07-29 Richard Guenther <rguenther@suse.de> 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
Diffstat (limited to 'gcc/convert.c')
-rw-r--r--gcc/convert.c9
1 files changed, 1 insertions, 8 deletions
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,