shithub: scc

Download patch

ref: a73645af515b2acd8071837597a4a18b649ee9be
parent: a7de023df75d9812c925ec5655be09ef0c02646e
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Fri Nov 12 03:12:09 EST 2021

tests/cc: Add test 0186-dec-ary.c

This test is added to verify correctness of post operators
with operands containing side effects.

--- /dev/null
+++ b/tests/cc/execute/0186-dec-ary.c
@@ -1,0 +1,23 @@
+struct node {
+	int index;
+};
+
+struct node nodes[2];
+
+int
+main(void)
+{
+	int d = 1, c;
+
+	d = 1;
+	c = nodes[--d].index++;
+	if (d != 0 || nodes[0].index != 1)
+		return 1;
+
+	d = -1;
+	c = nodes[++d].index--;
+	if (d != 0 || nodes[0].index != 0)
+		return 2;
+
+	return 0;
+}
--- a/tests/cc/execute/scc-tests.lst
+++ b/tests/cc/execute/scc-tests.lst
@@ -176,3 +176,4 @@
 0183-negenum.c
 0184-esc-macro.c
 0185-esc-macro2.c
+0186-dec-ary.c