aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2009-01-09 14:41:08 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2009-01-09 14:41:08 +0100
commit4017e262b6c5c8dfbb225f3599bf5c08990e022f (patch)
tree4290b4558216fb8f894300391d450df99de641af /gcc/fold-const.c
parent76601ca966444e9cd7d1098d47e468bceb77e321 (diff)
downloadgcc-4017e262b6c5c8dfbb225f3599bf5c08990e022f.zip
gcc-4017e262b6c5c8dfbb225f3599bf5c08990e022f.tar.gz
gcc-4017e262b6c5c8dfbb225f3599bf5c08990e022f.tar.bz2
re PR middle-end/38771 (error: non-trivial conversion in unary operation)
PR middle-end/38771 * fold-const.c (fold_unary): For COMPOUND_EXPR and COND_EXPR, fold_convert arg0 operands to TREE_TYPE (op0) first. * gcc.c-torture/compile/pr38771.c: New test. From-SVN: r143202
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 9b4106b..820ca5a 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -8053,15 +8053,19 @@ fold_unary (enum tree_code code, tree type, tree op0)
{
if (TREE_CODE (arg0) == COMPOUND_EXPR)
return build2 (COMPOUND_EXPR, type, TREE_OPERAND (arg0, 0),
- fold_build1 (code, type, TREE_OPERAND (arg0, 1)));
+ fold_build1 (code, type,
+ fold_convert (TREE_TYPE (op0),
+ TREE_OPERAND (arg0, 1))));
else if (TREE_CODE (arg0) == COND_EXPR)
{
tree arg01 = TREE_OPERAND (arg0, 1);
tree arg02 = TREE_OPERAND (arg0, 2);
if (! VOID_TYPE_P (TREE_TYPE (arg01)))
- arg01 = fold_build1 (code, type, arg01);
+ arg01 = fold_build1 (code, type,
+ fold_convert (TREE_TYPE (op0), arg01));
if (! VOID_TYPE_P (TREE_TYPE (arg02)))
- arg02 = fold_build1 (code, type, arg02);
+ arg02 = fold_build1 (code, type,
+ fold_convert (TREE_TYPE (op0), arg02));
tem = fold_build3 (COND_EXPR, type, TREE_OPERAND (arg0, 0),
arg01, arg02);