OSDN Git Service

PR54945
authormpolacek <mpolacek@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 19 Oct 2012 17:03:07 +0000 (17:03 +0000)
committermpolacek <mpolacek@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 19 Oct 2012 17:03:07 +0000 (17:03 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@192619 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/fold-const.c

index 5e83d0f..e4ec7ab 100644 (file)
@@ -1,3 +1,12 @@
+2012-10-19  Marek Polacek  <polacek@redhat.com>
+
+       Backported from mainline
+       2012-10-19  Marek Polacek  <polacek@redhat.com>
+
+       PR middle-end/54945
+       * fold-const.c (fold_sign_changed_comparison):  Punt if folding
+       pointer/non-pointer comparison.
+
 2012-10-19  Alan Modra  <amodra@gmail.com>
 
        * configure.ac (HAVE_LD_NO_DOT_SYMS): Set if using gold.
index 4bf10de..5b4fc1f 100644 (file)
@@ -6771,12 +6771,14 @@ fold_sign_changed_comparison (location_t loc, enum tree_code code, tree type,
           && TREE_TYPE (TREE_OPERAND (arg1, 0)) == inner_type))
     return NULL_TREE;
 
-  if ((TYPE_UNSIGNED (inner_type) != TYPE_UNSIGNED (outer_type)
-       || POINTER_TYPE_P (inner_type) != POINTER_TYPE_P (outer_type))
+  if (TYPE_UNSIGNED (inner_type) != TYPE_UNSIGNED (outer_type)
       && code != NE_EXPR
       && code != EQ_EXPR)
     return NULL_TREE;
 
+  if (POINTER_TYPE_P (inner_type) != POINTER_TYPE_P (outer_type))
+    return NULL_TREE;
+
   if (TREE_CODE (arg1) == INTEGER_CST)
     arg1 = force_fit_type_double (inner_type, tree_to_double_int (arg1),
                                  0, TREE_OVERFLOW (arg1));