From d1cdd0839b4ef436dc8f43043d242bd49ecb28c6 Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Tue, 22 Mar 2022 01:58:22 -0700 Subject: init: Allow empty initializers --- test/initializer-empty-struct.c | 5 +++++ test/initializer-empty-struct.qbe | 8 ++++++++ test/initializer-empty.c | 4 ++++ test/initializer-empty.qbe | 8 ++++++++ 4 files changed, 25 insertions(+) create mode 100644 test/initializer-empty-struct.c create mode 100644 test/initializer-empty-struct.qbe create mode 100644 test/initializer-empty.c create mode 100644 test/initializer-empty.qbe (limited to 'test') diff --git a/test/initializer-empty-struct.c b/test/initializer-empty-struct.c new file mode 100644 index 0000000..01538f5 --- /dev/null +++ b/test/initializer-empty-struct.c @@ -0,0 +1,5 @@ +struct s {float x; long y;}; +struct s s = {}; +void f(void) { + struct s t = {}; +} diff --git a/test/initializer-empty-struct.qbe b/test/initializer-empty-struct.qbe new file mode 100644 index 0000000..9bbfb34 --- /dev/null +++ b/test/initializer-empty-struct.qbe @@ -0,0 +1,8 @@ +export data $s = align 8 { z 16 } +export +function $f() { +@start.1 + %.1 =l alloc8 16 +@body.2 + ret +} diff --git a/test/initializer-empty.c b/test/initializer-empty.c new file mode 100644 index 0000000..e3e444c --- /dev/null +++ b/test/initializer-empty.c @@ -0,0 +1,4 @@ +int x = {}; +void f(void) { + int y = {}; +} diff --git a/test/initializer-empty.qbe b/test/initializer-empty.qbe new file mode 100644 index 0000000..2ed8249 --- /dev/null +++ b/test/initializer-empty.qbe @@ -0,0 +1,8 @@ +export data $x = align 4 { z 4 } +export +function $f() { +@start.1 + %.1 =l alloc4 4 +@body.2 + ret +} -- cgit v1.2.3