OSDN Git Service

PR middle-end/38771
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 9 Jan 2009 13:41:08 +0000 (13:41 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 9 Jan 2009 13:41:08 +0000 (13:41 +0000)
* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@143202 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr38771.c [new file with mode: 0644]

index 03a9e87..3a9d0e1 100644 (file)
@@ -1,3 +1,9 @@
+2009-01-09  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/38771
+       * fold-const.c (fold_unary): For COMPOUND_EXPR and COND_EXPR,
+       fold_convert arg0 operands to TREE_TYPE (op0) first.
+
 2009-01-08  Vladimir Makarov  <vmakarov@redhat.com>
 
        * params.def (ira-max-conflict-table-size): Decrease default value
index 9b4106b..820ca5a 100644 (file)
@@ -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);
 
index 2874af0..199cd6e 100644 (file)
@@ -1,3 +1,8 @@
+2009-01-09  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/38771
+       * gcc.c-torture/compile/pr38771.c: New test.
+
 2009-01-08  Nathan Froyd  <froydnj@codesourcery.com>
 
        * gcc.dg/pr34856.c: Ignore irrelevant warning.
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr38771.c b/gcc/testsuite/gcc.c-torture/compile/pr38771.c
new file mode 100644 (file)
index 0000000..7988680
--- /dev/null
@@ -0,0 +1,7 @@
+/* PR middle-end/38771 */
+
+unsigned long long
+foo (long long x)
+{
+  return -(unsigned long long) (x ? : x);
+}