summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.c-torture/execute/20000715-1.c
diff options
context:
space:
mode:
authormeissner <meissner@138bc75d-0d04-0410-961f-82ee72b054a4>2000-07-15 14:58:53 +0000
committermeissner <meissner@138bc75d-0d04-0410-961f-82ee72b054a4>2000-07-15 14:58:53 +0000
commite8d76c538c974244d02fa12d3936679a3f9c8976 (patch)
treecc186924767d7116187ea8c5addebe72555b7ae8 /gcc/testsuite/gcc.c-torture/execute/20000715-1.c
parent8b4e3c9506e2271e804a364059b40c2b9207f199 (diff)
downloadgcc-e8d76c538c974244d02fa12d3936679a3f9c8976.tar.gz
Fix (<cond> ? FOO++ : BAR++) == 2 from misoptimizing FOO++ into ++FOO without bumping up the comparison value
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@35046 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gcc.c-torture/execute/20000715-1.c')
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/20000715-1.c118
1 files changed, 118 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.c-torture/execute/20000715-1.c b/gcc/testsuite/gcc.c-torture/execute/20000715-1.c
new file mode 100644
index 00000000000..43af11480b4
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/20000715-1.c
@@ -0,0 +1,118 @@
+void abort(void);
+void exit(int);
+
+void
+test1(void)
+{
+ int x = 3, y = 2;
+
+ if ((x < y ? x++ : y++) != 2)
+ abort ();
+
+ if (x != 3)
+ abort ();
+
+ if (y != 3)
+ abort ();
+}
+
+void
+test2(void)
+{
+ int x = 3, y = 2, z;
+
+ z = (x < y) ? x++ : y++;
+ if (z != 2)
+ abort ();
+
+ if (x != 3)
+ abort ();
+
+ if (y != 3)
+ abort ();
+}
+
+void
+test3(void)
+{
+ int x = 3, y = 2;
+ int xx = 3, yy = 2;
+
+ if ((xx < yy ? x++ : y++) != 2)
+ abort ();
+
+ if (x != 3)
+ abort ();
+
+ if (y != 3)
+ abort ();
+}
+
+int x, y;
+
+static void
+init_xy(void)
+{
+ x = 3;
+ y = 2;
+}
+
+void
+test4(void)
+{
+ init_xy();
+ if ((x < y ? x++ : y++) != 2)
+ abort ();
+
+ if (x != 3)
+ abort ();
+
+ if (y != 3)
+ abort ();
+}
+
+void
+test5(void)
+{
+ int z;
+
+ init_xy();
+ z = (x < y) ? x++ : y++;
+ if (z != 2)
+ abort ();
+
+ if (x != 3)
+ abort ();
+
+ if (y != 3)
+ abort ();
+}
+
+void
+test6(void)
+{
+ int xx = 3, yy = 2;
+ int z;
+
+ init_xy();
+ z = (xx < y) ? x++ : y++;
+ if (z != 2)
+ abort ();
+
+ if (x != 3)
+ abort ();
+
+ if (y != 3)
+ abort ();
+}
+
+int
+main(){
+ test1 ();
+ test2 ();
+ test3 ();
+ test4 ();
+ test5 ();
+ test6 ();
+ exit (0);
+}