summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.c-torture
diff options
context:
space:
mode:
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2002-06-15 00:43:20 +0000
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2002-06-15 00:43:20 +0000
commit77a5ccfcd868c74a5afbc618cf6293819898023b (patch)
treecb43c98a6b0a85672d8d8ac92995e13c0a249962 /gcc/testsuite/gcc.c-torture
parent4131f952ed0463ea672dd27a07d376a9d30dbe43 (diff)
downloadgcc-77a5ccfcd868c74a5afbc618cf6293819898023b.tar.gz
New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@54630 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gcc.c-torture')
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/20020614-1.c41
1 files changed, 41 insertions, 0 deletions
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
index 00000000000..bcbaed8ae8e
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/20020614-1.c
@@ -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);
+}