aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2019-02-22 21:28:43 -0800
committerMichael Forney <mforney@mforney.org>2019-02-22 21:45:00 -0800
commite8863971221faba91357310b0c8be0fb2951ef22 (patch)
treeb661be7729fe3c3c3414101e4fd45d287c78446b /tests
parent8b10f07e6260895025a4ea0efa05b8bd57ca92d9 (diff)
downloadcproc-e8863971221faba91357310b0c8be0fb2951ef22.tar.xz
Fix size of incomplete array types initialized with strings
updatearray takes an index, so was allocating an extra byte.
Diffstat (limited to 'tests')
-rw-r--r--tests/initializer-string.c4
-rw-r--r--tests/initializer-string.qbe20
2 files changed, 24 insertions, 0 deletions
diff --git a/tests/initializer-string.c b/tests/initializer-string.c
new file mode 100644
index 0000000..c92f897
--- /dev/null
+++ b/tests/initializer-string.c
@@ -0,0 +1,4 @@
+char x[] = "hello";
+void f(void) {
+ char y[] = "hello";
+}
diff --git a/tests/initializer-string.qbe b/tests/initializer-string.qbe
new file mode 100644
index 0000000..ba992da
--- /dev/null
+++ b/tests/initializer-string.qbe
@@ -0,0 +1,20 @@
+export data $x = align 1 { b "hello", z 1, }
+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, 5
+ storeb 0, %.7
+ ret
+}