scc

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

commit 65c1d7d2f64cb02e25a6bc4cf7956154c0bfef83
parent ac186af698aa2ab93a70d73f39151d2c8d269e65
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Wed, 18 Jan 2023 20:38:00 +0100

tests/cc: Add execute/0218-initialize.c

Diffstat:
Atests/cc/execute/0218-initialize.c | 37+++++++++++++++++++++++++++++++++++++
Mtests/cc/execute/scc-tests.lst | 1+
2 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/tests/cc/execute/0218-initialize.c b/tests/cc/execute/0218-initialize.c @@ -0,0 +1,37 @@ +struct f { + int fd; + unsigned char *buf; + unsigned char unbuf[1]; + unsigned char *rp; +}; + +#define stderr (&buf[2]) + +struct f f; + +struct f buf[] = { + { + .fd = 0, + }, + { + .fd = -1, + .buf = f.unbuf, + }, + { + .fd = 2, + .buf = stderr->unbuf, + .rp = stderr->unbuf, + }, +}; + +int +main() +{ + if (buf[2].unbuf != buf[2].rp) + return 1; + if (buf[2].unbuf != buf[2].buf) + return 2; + if (buf[1].buf != f.unbuf) + return 3; + return 0; +} diff --git a/tests/cc/execute/scc-tests.lst b/tests/cc/execute/scc-tests.lst @@ -208,3 +208,4 @@ 0215-ret_struct.c 0216-initialize.c [TODO] 0217-lchar.c +0218-initialize.c [TODO]