OSDN Git Service

2008-02-27 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 27 Feb 2008 13:17:17 +0000 (13:17 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 27 Feb 2008 13:17:17 +0000 (13:17 +0000)
PR middle-end/25290
* fold-const.c (fold_unary): Return the correct argument,
converted to the result type.

* gcc.c-torture/execute/pr35390.c: New testcase.

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

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

index c8e74f5..aff90b8 100644 (file)
@@ -1,5 +1,11 @@
 2008-02-27  Richard Guenther  <rguenther@suse.de>
 
 2008-02-27  Richard Guenther  <rguenther@suse.de>
 
+       PR middle-end/25290
+       * fold-const.c (fold_unary): Return the correct argument,
+       converted to the result type.
+
+2008-02-27  Richard Guenther  <rguenther@suse.de>
+
        PR middle-end/34971
        * expr.c (expand_expr_real_1): Assert on rotates that operate
        on partial modes.
        PR middle-end/34971
        * expr.c (expand_expr_real_1): Assert on rotates that operate
        on partial modes.
index f6a73ef..987acf1 100644 (file)
@@ -8340,7 +8340,7 @@ fold_unary (enum tree_code code, tree type, tree op0)
       if (TREE_CODE (arg0) == INTEGER_CST)
         return fold_not_const (arg0, type);
       else if (TREE_CODE (arg0) == BIT_NOT_EXPR)
       if (TREE_CODE (arg0) == INTEGER_CST)
         return fold_not_const (arg0, type);
       else if (TREE_CODE (arg0) == BIT_NOT_EXPR)
-       return TREE_OPERAND (op0, 0);
+       return fold_convert (type, TREE_OPERAND (arg0, 0));
       /* Convert ~ (-A) to A - 1.  */
       else if (INTEGRAL_TYPE_P (type) && TREE_CODE (arg0) == NEGATE_EXPR)
        return fold_build2 (MINUS_EXPR, type,
       /* Convert ~ (-A) to A - 1.  */
       else if (INTEGRAL_TYPE_P (type) && TREE_CODE (arg0) == NEGATE_EXPR)
        return fold_build2 (MINUS_EXPR, type,
index 8d5fff7..51196bb 100644 (file)
@@ -1,3 +1,8 @@
+2008-02-27  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/25290
+       * gcc.c-torture/execute/pr35390.c: New testcase.
+
 2008-02-27  Samuel Tardieu  <sam@rfc1149.net>
 
        PR ada/22255
 2008-02-27  Samuel Tardieu  <sam@rfc1149.net>
 
        PR ada/22255
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr35390.c b/gcc/testsuite/gcc.c-torture/execute/pr35390.c
new file mode 100644 (file)
index 0000000..7103a9b
--- /dev/null
@@ -0,0 +1,13 @@
+extern void abort (void);
+
+unsigned int foo (int n)
+{
+  return ~((unsigned int)~n);
+}
+
+int main()
+{
+  if (foo(0) != 0)
+    abort ();
+  return 0;
+}