scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit c0e9509336994bf4e7c5cf484ebe7ca374e4da81
parent 9ee4cece6aca3287438981fe8c6c10b274cc0bc2
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri, 12 Nov 2021 08:12:09 +0100

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

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

Diffstat:
Atests/cc/execute/0186-dec-ary.c | 23+++++++++++++++++++++++
Mtests/cc/execute/scc-tests.lst | 1+
2 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/tests/cc/execute/0186-dec-ary.c b/tests/cc/execute/0186-dec-ary.c @@ -0,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; +} diff --git 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