diff options
author | Richard Guenther <rguenther@suse.de> | 2010-07-29 10:59:54 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2010-07-29 10:59:54 +0000 |
commit | 6befd6b053f32de162090b6ee6316c6ac5bcaef0 (patch) | |
tree | 6a70422b360d8f8cb89bc1cd1f4fee1cfffc246a /gcc/convert.c | |
parent | 6cfcf3eda65ef5ea3f3a5f3e16bb89b48cef1dce (diff) | |
download | gcc-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.c | 9 |
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, |