scc

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

commit 532456cdf90cecdbc0bc80f1e4a6d002accb3bb2
parent b36e3b65309bdaa5515cb2d9a6313998e174e35d
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sat, 13 Nov 2021 17:24:12 +0100

cc1: Add 0187-zero-struct.c

This test check correctness of the padding between elements
of an initializer.

Diffstat:
Atests/cc/execute/0187-zero-struct.c | 24++++++++++++++++++++++++
Mtests/cc/execute/scc-tests.lst | 1+
2 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/tests/cc/execute/0187-zero-struct.c b/tests/cc/execute/0187-zero-struct.c @@ -0,0 +1,24 @@ +struct json_node { + int type; + char *name; +}; + +int +main(void) +{ + struct json_node nodes[16] = { { 0 } }; + char sentinel[] = { + 0x98, 0x98, 0x98, 0x98, + 0x98, 0x98, 0x98, 0x98, + 0x98, 0x98, 0x98, 0x98, + 0x98, 0x98, 0x98, 0x98, + }; + int i; + + for (i = 0; i < 16; i++) { + if (nodes[i].name || nodes[i].type) + return i+1; + } + + return 0; +} diff --git a/tests/cc/execute/scc-tests.lst b/tests/cc/execute/scc-tests.lst @@ -177,3 +177,4 @@ 0184-esc-macro.c 0185-esc-macro2.c 0186-dec-ary.c +0187-zero-struct.c