OSDN Git Service

PR c/14092
authorbonzini <bonzini@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 10 Feb 2004 13:41:16 +0000 (13:41 +0000)
committerbonzini <bonzini@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 10 Feb 2004 13:41:16 +0000 (13:41 +0000)
* gcc.dg/pr14092-1.c: New testcase.
* fold-const.c (fold) <NEGATE_EXPR>: Convert result of
negate_expr back to the original type.

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

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

index 1f6b748..c235d08 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 3f68051..71f1e9b 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 b0bcf5f..a22f644 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;
+}
+