* c-typeck.c (pointer_diff): Check for POINTER_PLUS_EXPR, not
authorbernds <bernds@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 5 Mar 2012 22:48:30 +0000 (22:48 +0000)
committerbernds <bernds@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 5 Mar 2012 22:48:30 +0000 (22:48 +0000)
PLUS_EXPR.

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

gcc/ChangeLog
gcc/c-typeck.c

index ad4bfb0..8897a63 100644 (file)
@@ -1,3 +1,8 @@
+2012-03-05  Bernd Schmidt  <bernds@codesourcery.com>
+
+       * c-typeck.c (pointer_diff): Check for POINTER_PLUS_EXPR, not
+       PLUS_EXPR.
+
 2012-03-05  Richard Henderson  <rth@redhat.com>
 
        * genemit.c (main): Include "target.h" in insn-emit.c.
index 2de1e5c..61bb8fd 100644 (file)
@@ -3447,7 +3447,9 @@ pointer_diff (location_t loc, tree op0, tree op1)
   else
     con1 = op1;
 
-  if (TREE_CODE (con0) == PLUS_EXPR)
+  gcc_assert (TREE_CODE (con0) != PLUS_EXPR
+             && TREE_CODE (con1) != PLUS_EXPR);
+  if (TREE_CODE (con0) == POINTER_PLUS_EXPR)
     {
       lit0 = TREE_OPERAND (con0, 1);
       con0 = TREE_OPERAND (con0, 0);
@@ -3455,7 +3457,7 @@ pointer_diff (location_t loc, tree op0, tree op1)
   else
     lit0 = integer_zero_node;
 
-  if (TREE_CODE (con1) == PLUS_EXPR)
+  if (TREE_CODE (con1) == POINTER_PLUS_EXPR)
     {
       lit1 = TREE_OPERAND (con1, 1);
       con1 = TREE_OPERAND (con1, 0);