]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR middle-end/14092 (fold strips conversion from pointer to integer)
authorPaolo Bonzini <bonzini@gnu.org>
Tue, 10 Feb 2004 13:41:16 +0000 (13:41 +0000)
committerPaolo Bonzini <bonzini@gcc.gnu.org>
Tue, 10 Feb 2004 13:41:16 +0000 (13:41 +0000)
PR c/14092
* gcc.dg/pr14092-1.c: New testcase.
* fold-const.c (fold) <NEGATE_EXPR>: Convert result of
negate_expr back to the original type.

From-SVN: r77602

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr14092-1.c [new file with mode: 0644]

index 1f6b7482152b5a7b2d6d37ab577ba5e14ef0766a..c235d08ef5002eb68e322259f17e539d4b000e38 100644 (file)
@@ -1,3 +1,9 @@
+2004-02-10  Paolo Bonzini  <bonzini@gnu.org>
+
+       PR c/14092
+       * fold-const.c (fold) <NEGATE_EXPR>: Convert result of
+       negate_expr back to the original type.
+
 2004-02-10  Alan Modra  <amodra@bigpond.net.au>
 
        * config/rs6000/linux64.h (MD_FALLBACK_FRAME_STATE_FOR): Don't
index 3f68051da2d8a715f6ad61f0125cf413e4d7402b..71f1e9bce0957973f31b1ea524a0ab390628898e 100644 (file)
@@ -5785,7 +5785,7 @@ fold (tree expr)
 
     case NEGATE_EXPR:
       if (negate_expr_p (arg0))
-       return negate_expr (arg0);
+       return fold_convert (type, negate_expr (arg0));
       return t;
 
     case ABS_EXPR:
index b0bcf5fee414a79e811490f88c02cac04536af41..a22f644a4abf9fc6c65cd1df23236824cb669c1f 100644 (file)
@@ -1,3 +1,9 @@
+2004-02-10  Paolo Bonzini  <bonzini@gnu.org>
+
+       PR c/14092
+
+       * gcc.dg/pr14092-1.c: New testcase.
+
 2004-02-10  Alan Modra  <amodra@bigpond.net.au>
 
        * gcc.dg/cpp/assert4.c: Fix typo last change.
diff --git a/gcc/testsuite/gcc.dg/pr14092-1.c b/gcc/testsuite/gcc.dg/pr14092-1.c
new file mode 100644 (file)
index 0000000..86076c2
--- /dev/null
@@ -0,0 +1,17 @@
+/* PR c/14092
+ * Origin: bonzini@gnu.org
+ * rejects-valid
+ */
+/* { dg-do compile } */
+
+typedef struct _PLCI {
+  unsigned char x;
+  unsigned char buf[1];
+} PLCI;
+
+
+void nl_ind(PLCI * plci)
+{
+  plci->x = -((int)(plci->buf)) & 3;
+}
+