From fca0b26275a82c480a5286c281834dad6887b410 Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Mon, 15 Apr 2019 01:11:08 -0700 Subject: Handle static sub-initializers --- tests/initializer-replace-local.c | 10 ++++++++++ tests/initializer-replace-local.qbe | 22 ++++++++++++++++++++++ tests/initializer-replace-static.c | 6 ++++++ tests/initializer-replace-static.qbe | 1 + tests/initializer-replace.c | 10 ---------- tests/initializer-replace.qbe | 22 ---------------------- 6 files changed, 39 insertions(+), 32 deletions(-) create mode 100644 tests/initializer-replace-local.c create mode 100644 tests/initializer-replace-local.qbe create mode 100644 tests/initializer-replace-static.c create mode 100644 tests/initializer-replace-static.qbe delete mode 100644 tests/initializer-replace.c delete mode 100644 tests/initializer-replace.qbe (limited to 'tests') diff --git a/tests/initializer-replace-local.c b/tests/initializer-replace-local.c new file mode 100644 index 0000000..8b93ef2 --- /dev/null +++ b/tests/initializer-replace-local.c @@ -0,0 +1,10 @@ +void f(void) { + struct { + char s[6]; + } x = { + .s[0] = 'x', + .s[4] = 'y', + .s = "hello", + .s[1] = 'a', + }; +} diff --git a/tests/initializer-replace-local.qbe b/tests/initializer-replace-local.qbe new file mode 100644 index 0000000..72ad90a --- /dev/null +++ b/tests/initializer-replace-local.qbe @@ -0,0 +1,22 @@ +export +function $f() { +@start.1 + %.1 =l alloc4 6 +@body.2 + %.2 =l add %.1, 0 + storeb 104, %.2 + %.3 =l add %.1, 1 + storeb 101, %.3 + %.4 =l add %.1, 2 + storeb 108, %.4 + %.5 =l add %.1, 3 + storeb 108, %.5 + %.6 =l add %.1, 4 + storeb 111, %.6 + %.7 =l add %.1, 1 + %.8 =w copy 97 + storeb %.8, %.7 + %.9 =l add %.1, 5 + storeb 0, %.9 + ret +} diff --git a/tests/initializer-replace-static.c b/tests/initializer-replace-static.c new file mode 100644 index 0000000..c1fa376 --- /dev/null +++ b/tests/initializer-replace-static.c @@ -0,0 +1,6 @@ +struct { + char s[6]; +} x = { + .s = "hello", + .s[1] = 'a', +}; diff --git a/tests/initializer-replace-static.qbe b/tests/initializer-replace-static.qbe new file mode 100644 index 0000000..18b774e --- /dev/null +++ b/tests/initializer-replace-static.qbe @@ -0,0 +1 @@ +export data $x = align 1 { b "hallo", z 1, } diff --git a/tests/initializer-replace.c b/tests/initializer-replace.c deleted file mode 100644 index 8b93ef2..0000000 --- a/tests/initializer-replace.c +++ /dev/null @@ -1,10 +0,0 @@ -void f(void) { - struct { - char s[6]; - } x = { - .s[0] = 'x', - .s[4] = 'y', - .s = "hello", - .s[1] = 'a', - }; -} diff --git a/tests/initializer-replace.qbe b/tests/initializer-replace.qbe deleted file mode 100644 index 72ad90a..0000000 --- a/tests/initializer-replace.qbe +++ /dev/null @@ -1,22 +0,0 @@ -export -function $f() { -@start.1 - %.1 =l alloc4 6 -@body.2 - %.2 =l add %.1, 0 - storeb 104, %.2 - %.3 =l add %.1, 1 - storeb 101, %.3 - %.4 =l add %.1, 2 - storeb 108, %.4 - %.5 =l add %.1, 3 - storeb 108, %.5 - %.6 =l add %.1, 4 - storeb 111, %.6 - %.7 =l add %.1, 1 - %.8 =w copy 97 - storeb %.8, %.7 - %.9 =l add %.1, 5 - storeb 0, %.9 - ret -} -- cgit v1.2.3