scc

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

commit f8d3d7e2999e57ccbde4c95651b7b056622e0dee
parent 433adcd26eaa7d73aaa761abfabc90c3e850e41e
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