re PR c/8439 (empty struct causes crash)
authorEric Botcazou <ebotcazou@libertysurf.fr>
Mon, 11 Nov 2002 05:38:22 +0000 (06:38 +0100)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Mon, 11 Nov 2002 05:38:22 +0000 (05:38 +0000)
PR c/8439
* recog.c (validate_replace_rtx_1) [PLUS]: Simplify only
if there is something new to be simplified.

From-SVN: r59005

gcc/ChangeLog
gcc/recog.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/20021110.c [new file with mode: 0644]

index 308e81747f8bf9794b10c5ab9536341d7dfe3ed1..b29de8927fff9450ea6d9377a63acfb849178c0b 100644 (file)
@@ -1,3 +1,9 @@
+2002-11-09  Eric Botcazou  <ebotcazou@libertysurf.fr>
+
+       PR c/8439
+       * recog.c (validate_replace_rtx_1) [PLUS]: Simplify only
+       if there is something new to be simplified.
+
 2002-11-10  H.J. Lu <hjl@gnu.org>
 
        * calls.c (PUSH_ARGS_REVERSED): Define only if not defined.
index b40867bf7a312fbb1b5d1bfdb22db392aedee6a8..649f3665d10ac69560e724ca552579962e2753b4 100644 (file)
@@ -522,10 +522,10 @@ validate_replace_rtx_1 (loc, from, to, object)
     {
     case PLUS:
       /* If we have a PLUS whose second operand is now a CONST_INT, use
-         plus_constant to try to simplify it.
+         simplify_gen_binary to try to simplify it.
          ??? We may want later to remove this, once simplification is
          separated from this function.  */
-      if (GET_CODE (XEXP (x, 1)) == CONST_INT)
+      if (GET_CODE (XEXP (x, 1)) == CONST_INT && XEXP (x, 1) == to)
        validate_change (object, loc,
                         simplify_gen_binary
                         (PLUS, GET_MODE (x), XEXP (x, 0), XEXP (x, 1)), 1);
index e67e784d0e3925ca7604c00bf4d32ad3e12ddaea..99af5fe5eeb9c0ff9b17b5ca6805f834fe769aa3 100644 (file)
@@ -1,3 +1,8 @@
+2002-11-09  Eric Botcazou  <ebotcazou@libertysurf.fr>
+
+       PR c/8439
+       * gcc.dg/testsuite/20021110.c: New test.
+       
 2002-11-10  Mark Mitchell  <mark@codesourcery.com>
 
        * g++.dg/abi/vthunk3.C: Run only on x86.
diff --git a/gcc/testsuite/gcc.dg/20021110.c b/gcc/testsuite/gcc.dg/20021110.c
new file mode 100644 (file)
index 0000000..dd2aa7e
--- /dev/null
@@ -0,0 +1,10 @@
+/* PR c/8439 */
+/* Verify that GCC properly handles null increments. */
+
+struct empty {
+};
+
+void foo(struct empty *p)
+{
+   p++;
+}