OSDN Git Service

New.
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 15 Jun 2002 00:43:20 +0000 (00:43 +0000)
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 15 Jun 2002 00:43:20 +0000 (00:43 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@54630 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/testsuite/gcc.c-torture/execute/20020614-1.c [new file with mode: 0644]

diff --git a/gcc/testsuite/gcc.c-torture/execute/20020614-1.c b/gcc/testsuite/gcc.c-torture/execute/20020614-1.c
new file mode 100644 (file)
index 0000000..bcbaed8
--- /dev/null
@@ -0,0 +1,41 @@
+/* PR c/6677 */
+/* Verify that GCC doesn't perform illegal simplifications
+   when folding constants.  */
+
+#include <limits.h>
+
+extern void abort (void);
+extern void exit (int);
+
+int main (void)
+{
+  int i;
+  signed char j;
+  unsigned char k;
+
+  i = SCHAR_MAX;
+
+  j = ((signed char) (i << 1)) / 2;
+
+  if (j != -1)
+    abort();
+
+  j = ((signed char) (i * 2)) / 2;
+
+  if (j != -1)
+    abort();
+
+  i = UCHAR_MAX;
+
+  k = ((unsigned char) (i << 1)) / 2;
+
+  if (k != UCHAR_MAX/2)
+    abort();
+
+  k = ((unsigned char) (i * 2)) / 2;
+
+  if (k != UCHAR_MAX/2)
+    abort();
+
+  exit(0);
+}