aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2019-04-16 12:26:18 -0700
committerMichael Forney <mforney@mforney.org>2019-04-16 12:26:18 -0700
commitde004660726acb148bf0022706b7019ca560172d (patch)
treede95581449d1db324c074859615501cf8f0bc5c3 /test
parent953e1e6f287d8bc00b2ef8d2197a20a549274eb3 (diff)
downloadcproc-de004660726acb148bf0022706b7019ca560172d.tar.xz
tests -> test
Diffstat (limited to 'test')
-rw-r--r--test/add-int-pointer.c4
-rw-r--r--test/add-int-pointer.qbe10
-rw-r--r--test/alignas.c1
-rw-r--r--test/alignas.qbe1
-rw-r--r--test/basic.c3
-rw-r--r--test/basic.qbe6
-rw-r--r--test/bitfield-compound-assign.c7
-rw-r--r--test/bitfield-compound-assign.qbe21
-rw-r--r--test/bitfield-load-signed.c7
-rw-r--r--test/bitfield-load-signed.qbe14
-rw-r--r--test/bitfield-load-unsigned.c7
-rw-r--r--test/bitfield-load-unsigned.qbe14
-rw-r--r--test/builtin-alloca.c3
-rw-r--r--test/builtin-alloca.qbe12
-rw-r--r--test/builtin-constant-p.c3
-rw-r--r--test/builtin-constant-p.qbe2
-rw-r--r--test/builtin-inff.c1
-rw-r--r--test/builtin-inff.qbe1
-rw-r--r--test/builtin-nanf.c1
-rw-r--r--test/builtin-nanf.qbe1
-rw-r--r--test/builtin-va-copy.c4
-rw-r--r--test/builtin-va-copy.qbe20
-rw-r--r--test/cast-bool-char.c3
-rw-r--r--test/cast-bool-char.qbe10
-rw-r--r--test/common-real-int-sign.c3
-rw-r--r--test/common-real-int-sign.qbe10
-rw-r--r--test/compare-char.c3
-rw-r--r--test/compare-char.qbe11
-rw-r--r--test/compatible-enum-types.c4
-rw-r--r--test/compatible-enum-types.qbe2
-rw-r--r--test/compatible-function-types.c17
-rw-r--r--test/compatible-function-types.qbe16
-rw-r--r--test/compound-assignment.c4
-rw-r--r--test/compound-assignment.qbe18
-rw-r--r--test/compound-literal-static.c1
-rw-r--r--test/compound-literal-static.qbe2
-rw-r--r--test/const-expr-div.c1
-rw-r--r--test/const-expr-div.qbe1
-rw-r--r--test/const-expr-mod.c1
-rw-r--r--test/const-expr-mod.qbe1
-rw-r--r--test/const-expr-shr.c1
-rw-r--r--test/const-expr-shr.qbe1
-rw-r--r--test/const-init.c1
-rw-r--r--test/const-init.qbe1
-rw-r--r--test/escaped-newline.c2
-rw-r--r--test/escaped-newline.qbe1
-rw-r--r--test/float-const-leading-dot.c1
-rw-r--r--test/float-const-leading-dot.qbe1
-rw-r--r--test/float-promote.c8
-rw-r--r--test/float-promote.qbe11
-rw-r--r--test/float-to-uint32.c4
-rw-r--r--test/float-to-uint32.qbe9
-rw-r--r--test/float-to-uint64.c4
-rw-r--r--test/float-to-uint64.qbe18
-rw-r--r--test/for-loop.c6
-rw-r--r--test/for-loop.qbe21
-rw-r--r--test/global-align.c1
-rw-r--r--test/global-align.qbe1
-rw-r--r--test/hello.c5
-rw-r--r--test/hello.qbe9
-rw-r--r--test/initializer-long-string.c1
-rw-r--r--test/initializer-long-string.qbe1
-rw-r--r--test/initializer-nested-array-address.c2
-rw-r--r--test/initializer-nested-array-address.qbe2
-rw-r--r--test/initializer-replace-local.c10
-rw-r--r--test/initializer-replace-local.qbe22
-rw-r--r--test/initializer-replace-static.c6
-rw-r--r--test/initializer-replace-static.qbe1
-rw-r--r--test/initializer-short-string.c3
-rw-r--r--test/initializer-short-string.qbe27
-rw-r--r--test/initializer-string-array.c3
-rw-r--r--test/initializer-string-array.qbe23
-rw-r--r--test/initializer-string.c4
-rw-r--r--test/initializer-string.qbe20
-rw-r--r--test/initializer-unsigned-string.c1
-rw-r--r--test/initializer-unsigned-string.qbe1
-rw-r--r--test/label-typedef.c4
-rw-r--r--test/label-typedef.qbe7
-rw-r--r--test/local-align.c3
-rw-r--r--test/local-align.qbe7
-rw-r--r--test/local-init.c6
-rw-r--r--test/local-init.qbe22
-rw-r--r--test/lvalue-conversion.c6
-rw-r--r--test/lvalue-conversion.qbe14
-rw-r--r--test/nested-array.c1
-rw-r--r--test/nested-array.qbe1
-rw-r--r--test/sizeof-compound-literal.c1
-rw-r--r--test/sizeof-compound-literal.qbe1
-rw-r--r--test/sizeof-postfix.c4
-rw-r--r--test/sizeof-postfix.qbe8
-rw-r--r--test/struct-copy.c8
-rw-r--r--test/struct-copy.qbe21
-rw-r--r--test/struct-passing.c11
-rw-r--r--test/struct-passing.qbe8
-rw-r--r--test/struct-return-1.c3
-rw-r--r--test/struct-return-1.qbe10
-rw-r--r--test/struct-return-2.c4
-rw-r--r--test/struct-return-2.qbe14
-rw-r--r--test/subtract-pointer.c3
-rw-r--r--test/subtract-pointer.qbe16
-rw-r--r--test/switch.c10
-rw-r--r--test/switch.qbe62
-rw-r--r--test/tentative.c2
-rw-r--r--test/tentative.qbe1
-rw-r--r--test/typedef-name.c4
-rw-r--r--test/typedef-name.qbe7
-rw-r--r--test/typedef.c2
-rw-r--r--test/typedef.qbe1
-rw-r--r--test/typeof.c20
-rw-r--r--test/typeof.qbe54
-rw-r--r--test/uint32-to-float.c4
-rw-r--r--test/uint32-to-float.qbe9
-rw-r--r--test/uint64-to-float.c4
-rw-r--r--test/uint64-to-float.qbe20
-rw-r--r--test/union-passing.c2
-rw-r--r--test/union-passing.qbe7
-rw-r--r--test/union.c4
-rw-r--r--test/union.qbe2
-rw-r--r--test/unused-return.c4
-rw-r--r--test/unused-return.qbe7
-rw-r--r--test/varargs.c12
-rw-r--r--test/varargs.qbe22
122 files changed, 927 insertions, 0 deletions
diff --git a/test/add-int-pointer.c b/test/add-int-pointer.c
new file mode 100644
index 0000000..be1a60f
--- /dev/null
+++ b/test/add-int-pointer.c
@@ -0,0 +1,4 @@
+int x[2];
+void f(void) {
+ 1 + x;
+}
diff --git a/test/add-int-pointer.qbe b/test/add-int-pointer.qbe
new file mode 100644
index 0000000..22825ee
--- /dev/null
+++ b/test/add-int-pointer.qbe
@@ -0,0 +1,10 @@
+export
+function $f() {
+@start.1
+@body.2
+ %.1 =l extsw 1
+ %.2 =l mul %.1, 4
+ %.3 =l add $x, %.2
+ ret
+}
+export data $x = align 4 { z 8 }
diff --git a/test/alignas.c b/test/alignas.c
new file mode 100644
index 0000000..394045d
--- /dev/null
+++ b/test/alignas.c
@@ -0,0 +1 @@
+_Alignas(int) char x[4];
diff --git a/test/alignas.qbe b/test/alignas.qbe
new file mode 100644
index 0000000..7cf0e40
--- /dev/null
+++ b/test/alignas.qbe
@@ -0,0 +1 @@
+export data $x = align 4 { z 4 }
diff --git a/test/basic.c b/test/basic.c
new file mode 100644
index 0000000..061ed7e
--- /dev/null
+++ b/test/basic.c
@@ -0,0 +1,3 @@
+int main(void) {
+ return 0;
+}
diff --git a/test/basic.qbe b/test/basic.qbe
new file mode 100644
index 0000000..40d18e9
--- /dev/null
+++ b/test/basic.qbe
@@ -0,0 +1,6 @@
+export
+function w $main() {
+@start.1
+@body.2
+ ret 0
+}
diff --git a/test/bitfield-compound-assign.c b/test/bitfield-compound-assign.c
new file mode 100644
index 0000000..5ca42e4
--- /dev/null
+++ b/test/bitfield-compound-assign.c
@@ -0,0 +1,7 @@
+struct {
+ int : 4, x : 9, : 3;
+} s;
+
+void f(void) {
+ s.x += 3;
+}
diff --git a/test/bitfield-compound-assign.qbe b/test/bitfield-compound-assign.qbe
new file mode 100644
index 0000000..829f5f6
--- /dev/null
+++ b/test/bitfield-compound-assign.qbe
@@ -0,0 +1,21 @@
+export
+function $f() {
+@start.1
+@body.2
+ %.1 =l copy $s
+ %.2 =l mul 0, 1
+ %.3 =l add %.1, %.2
+ %.4 =l copy %.3
+ %.5 =w loadsw %.4
+ %.6 =w shl %.5, 19
+ %.7 =w sar %.6, 23
+ %.8 =w add %.7, 3
+ %.9 =w loaduw %.4
+ %.10 =w and %.9, 18446744073709543439
+ %.11 =w shl %.8, 4
+ %.12 =w and %.11, 8176
+ %.13 =w or %.10, %.12
+ storew %.13, %.4
+ ret
+}
+export data $s = align 4 { z 4 }
diff --git a/test/bitfield-load-signed.c b/test/bitfield-load-signed.c
new file mode 100644
index 0000000..837ad24
--- /dev/null
+++ b/test/bitfield-load-signed.c
@@ -0,0 +1,7 @@
+struct {
+ signed : 4, x : 15, : 13;
+} s;
+
+void f(void) {
+ s.x;
+}
diff --git a/test/bitfield-load-signed.qbe b/test/bitfield-load-signed.qbe
new file mode 100644
index 0000000..bc3f457
--- /dev/null
+++ b/test/bitfield-load-signed.qbe
@@ -0,0 +1,14 @@
+export
+function $f() {
+@start.1
+@body.2
+ %.1 =l copy $s
+ %.2 =l mul 0, 1
+ %.3 =l add %.1, %.2
+ %.4 =l copy %.3
+ %.5 =w loadsw %.4
+ %.6 =w shl %.5, 13
+ %.7 =w sar %.6, 17
+ ret
+}
+export data $s = align 4 { z 4 }
diff --git a/test/bitfield-load-unsigned.c b/test/bitfield-load-unsigned.c
new file mode 100644
index 0000000..5a9e5fa
--- /dev/null
+++ b/test/bitfield-load-unsigned.c
@@ -0,0 +1,7 @@
+struct {
+ unsigned : 4, x : 15, : 13;
+} s;
+
+void f(void) {
+ s.x;
+}
diff --git a/test/bitfield-load-unsigned.qbe b/test/bitfield-load-unsigned.qbe
new file mode 100644
index 0000000..c4ea94b
--- /dev/null
+++ b/test/bitfield-load-unsigned.qbe
@@ -0,0 +1,14 @@
+export
+function $f() {
+@start.1
+@body.2
+ %.1 =l copy $s
+ %.2 =l mul 0, 1
+ %.3 =l add %.1, %.2
+ %.4 =l copy %.3
+ %.5 =w loaduw %.4
+ %.6 =w shl %.5, 13
+ %.7 =w shr %.6, 17
+ ret
+}
+export data $s = align 4 { z 4 }
diff --git a/test/builtin-alloca.c b/test/builtin-alloca.c
new file mode 100644
index 0000000..f086f19
--- /dev/null
+++ b/test/builtin-alloca.c
@@ -0,0 +1,3 @@
+void f(void) {
+ int *x = __builtin_alloca(32);
+}
diff --git a/test/builtin-alloca.qbe b/test/builtin-alloca.qbe
new file mode 100644
index 0000000..75a1fe1
--- /dev/null
+++ b/test/builtin-alloca.qbe
@@ -0,0 +1,12 @@
+export
+function $f() {
+@start.1
+ %.1 =l alloc8 8
+@body.2
+ %.2 =l add %.1, 0
+ %.3 =l extsw 32
+ %.4 =l alloc16 %.3
+ %.5 =l copy %.4
+ storel %.5, %.2
+ ret
+}
diff --git a/test/builtin-constant-p.c b/test/builtin-constant-p.c
new file mode 100644
index 0000000..fa16ed3
--- /dev/null
+++ b/test/builtin-constant-p.c
@@ -0,0 +1,3 @@
+int f(void);
+int x = __builtin_constant_p(1+2*3);
+int y = __builtin_constant_p(f());
diff --git a/test/builtin-constant-p.qbe b/test/builtin-constant-p.qbe
new file mode 100644
index 0000000..f92388f
--- /dev/null
+++ b/test/builtin-constant-p.qbe
@@ -0,0 +1,2 @@
+export data $x = align 4 { w 1, }
+export data $y = align 4 { w 0, }
diff --git a/test/builtin-inff.c b/test/builtin-inff.c
new file mode 100644
index 0000000..2dcd040
--- /dev/null
+++ b/test/builtin-inff.c
@@ -0,0 +1 @@
+float x = __builtin_inff();
diff --git a/test/builtin-inff.qbe b/test/builtin-inff.qbe
new file mode 100644
index 0000000..5eb8060
--- /dev/null
+++ b/test/builtin-inff.qbe
@@ -0,0 +1 @@
+export data $x = align 4 { s s_inf, }
diff --git a/test/builtin-nanf.c b/test/builtin-nanf.c
new file mode 100644
index 0000000..d239a46
--- /dev/null
+++ b/test/builtin-nanf.c
@@ -0,0 +1 @@
+float x = __builtin_nanf("");
diff --git a/test/builtin-nanf.qbe b/test/builtin-nanf.qbe
new file mode 100644
index 0000000..5fd7ac2
--- /dev/null
+++ b/test/builtin-nanf.qbe
@@ -0,0 +1 @@
+export data $x = align 4 { s s_nan, }
diff --git a/test/builtin-va-copy.c b/test/builtin-va-copy.c
new file mode 100644
index 0000000..7a69596
--- /dev/null
+++ b/test/builtin-va-copy.c
@@ -0,0 +1,4 @@
+void f(void) {
+ static __builtin_va_list a, b;
+ __builtin_va_copy(a, b);
+}
diff --git a/test/builtin-va-copy.qbe b/test/builtin-va-copy.qbe
new file mode 100644
index 0000000..7d88659
--- /dev/null
+++ b/test/builtin-va-copy.qbe
@@ -0,0 +1,20 @@
+data $.La.2 = align 8 { z 24 }
+data $.Lb.3 = align 8 { z 24 }
+export
+function $f() {
+@start.1
+@body.2
+ %.1 =l loadl $.Lb.3
+ storel %.1, $.La.2
+ %.2 =l add $.Lb.3, 8
+ %.3 =l add $.La.2, 8
+ %.4 =l loadl %.2
+ storel %.4, %.3
+ %.5 =l add %.2, 8
+ %.6 =l add %.3, 8
+ %.7 =l loadl %.5
+ storel %.7, %.6
+ %.8 =l add %.5, 8
+ %.9 =l add %.6, 8
+ ret
+}
diff --git a/test/cast-bool-char.c b/test/cast-bool-char.c
new file mode 100644
index 0000000..d05f575
--- /dev/null
+++ b/test/cast-bool-char.c
@@ -0,0 +1,3 @@
+int main(void) {
+ return (_Bool)(unsigned char)256;
+}
diff --git a/test/cast-bool-char.qbe b/test/cast-bool-char.qbe
new file mode 100644
index 0000000..81d4eba
--- /dev/null
+++ b/test/cast-bool-char.qbe
@@ -0,0 +1,10 @@
+export
+function w $main() {
+@start.1
+@body.2
+ %.1 =w copy 256
+ %.2 =w extub %.1
+ %.3 =w cnew %.2, 0
+ %.4 =w extub %.3
+ ret %.4
+}
diff --git a/test/common-real-int-sign.c b/test/common-real-int-sign.c
new file mode 100644
index 0000000..e31aaeb
--- /dev/null
+++ b/test/common-real-int-sign.c
@@ -0,0 +1,3 @@
+int main(void) {
+ return 0 > -1u;
+}
diff --git a/test/common-real-int-sign.qbe b/test/common-real-int-sign.qbe
new file mode 100644
index 0000000..09f4060
--- /dev/null
+++ b/test/common-real-int-sign.qbe
@@ -0,0 +1,10 @@
+export
+function w $main() {
+@start.1
+@body.2
+ %.1 =w copy 0
+ %.2 =w copy 0
+ %.3 =w sub %.2, 1
+ %.4 =w cugtw %.1, %.3
+ ret %.4
+}
diff --git a/test/compare-char.c b/test/compare-char.c
new file mode 100644
index 0000000..5219647
--- /dev/null
+++ b/test/compare-char.c
@@ -0,0 +1,3 @@
+int main(void) {
+ return (unsigned char)0 < (unsigned char)256;
+}
diff --git a/test/compare-char.qbe b/test/compare-char.qbe
new file mode 100644
index 0000000..a0a1c03
--- /dev/null
+++ b/test/compare-char.qbe
@@ -0,0 +1,11 @@
+export
+function w $main() {
+@start.1
+@body.2
+ %.1 =w copy 0
+ %.2 =w copy 256
+ %.3 =w extub %.1
+ %.4 =w extub %.2
+ %.5 =w cultw %.3, %.4
+ ret %.5
+}
diff --git a/test/compatible-enum-types.c b/test/compatible-enum-types.c
new file mode 100644
index 0000000..c605e90
--- /dev/null
+++ b/test/compatible-enum-types.c
@@ -0,0 +1,4 @@
+enum {A = 1} x;
+unsigned x;
+enum {B = -1} y;
+int y;
diff --git a/test/compatible-enum-types.qbe b/test/compatible-enum-types.qbe
new file mode 100644
index 0000000..a9a9224
--- /dev/null
+++ b/test/compatible-enum-types.qbe
@@ -0,0 +1,2 @@
+export data $x = align 4 { z 4 }
+export data $y = align 4 { z 4 }
diff --git a/test/compatible-function-types.c b/test/compatible-function-types.c
new file mode 100644
index 0000000..0e63a1c
--- /dev/null
+++ b/test/compatible-function-types.c
@@ -0,0 +1,17 @@
+void f1();
+void f1(int, void *);
+
+int f2();
+int f2(double);
+
+void f3() {}
+void f3(void);
+
+void f4(int, char *);
+void f4(int, char *);
+
+void f5(x, y) unsigned x; double y; {}
+void f5(unsigned, double);
+
+void f6(const char *, ...);
+void f6(const char[], ...);
diff --git a/test/compatible-function-types.qbe b/test/compatible-function-types.qbe
new file mode 100644
index 0000000..27d9b32
--- /dev/null
+++ b/test/compatible-function-types.qbe
@@ -0,0 +1,16 @@
+export
+function $f3() {
+@start.1
+@body.2
+ ret
+}
+export
+function $f5(w %.1, d %.3) {
+@start.3
+ %.2 =l alloc4 4
+ storew %.1, %.2
+ %.4 =l alloc8 8
+ stored %.3, %.4
+@body.4
+ ret
+}
diff --git a/test/compound-assignment.c b/test/compound-assignment.c
new file mode 100644
index 0000000..d7efcc6
--- /dev/null
+++ b/test/compound-assignment.c
@@ -0,0 +1,4 @@
+void f(void) {
+ int x[1] = {0}, *p = x;
+ *p++ += 1;
+}
diff --git a/test/compound-assignment.qbe b/test/compound-assignment.qbe
new file mode 100644
index 0000000..35e71a5
--- /dev/null
+++ b/test/compound-assignment.qbe
@@ -0,0 +1,18 @@
+export
+function $f() {
+@start.1
+ %.1 =l alloc4 4
+ %.3 =l alloc8 8
+@body.2
+ %.2 =l add %.1, 0
+ storew 0, %.2
+ %.4 =l add %.3, 0
+ storel %.1, %.4
+ %.5 =l loadl %.3
+ %.6 =l add %.5, 4
+ storel %.6, %.3
+ %.7 =w loadsw %.5
+ %.8 =w add %.7, 1
+ storew %.8, %.5
+ ret
+}
diff --git a/test/compound-literal-static.c b/test/compound-literal-static.c
new file mode 100644
index 0000000..1b1afc9
--- /dev/null
+++ b/test/compound-literal-static.c
@@ -0,0 +1 @@
+int *x = &(int){2};
diff --git a/test/compound-literal-static.qbe b/test/compound-literal-static.qbe
new file mode 100644
index 0000000..c18ec1d
--- /dev/null
+++ b/test/compound-literal-static.qbe
@@ -0,0 +1,2 @@
+data $.L.1 = align 4 { w 2, }
+export data $x = align 8 { l $.L.1, }
diff --git a/test/const-expr-div.c b/test/const-expr-div.c
new file mode 100644
index 0000000..3ea302a
--- /dev/null
+++ b/test/const-expr-div.c
@@ -0,0 +1 @@
+int x = -2 / -1;
diff --git a/test/const-expr-div.qbe b/test/const-expr-div.qbe
new file mode 100644
index 0000000..3faa638
--- /dev/null
+++ b/test/const-expr-div.qbe
@@ -0,0 +1 @@
+export data $x = align 4 { w 2, }
diff --git a/test/const-expr-mod.c b/test/const-expr-mod.c
new file mode 100644
index 0000000..024c94c
--- /dev/null
+++ b/test/const-expr-mod.c
@@ -0,0 +1 @@
+int x = -2 % -1;
diff --git a/test/const-expr-mod.qbe b/test/const-expr-mod.qbe
new file mode 100644
index 0000000..a67781d
--- /dev/null
+++ b/test/const-expr-mod.qbe
@@ -0,0 +1 @@
+export data $x = align 4 { w 0, }
diff --git a/test/const-expr-shr.c b/test/const-expr-shr.c
new file mode 100644
index 0000000..6a46b98
--- /dev/null
+++ b/test/const-expr-shr.c
@@ -0,0 +1 @@
+int x = -1 >> 1;
diff --git a/test/const-expr-shr.qbe b/test/const-expr-shr.qbe
new file mode 100644
index 0000000..675fc96
--- /dev/null
+++ b/test/const-expr-shr.qbe
@@ -0,0 +1 @@
+export data $x = align 4 { w 18446744073709551615, }
diff --git a/test/const-init.c b/test/const-init.c
new file mode 100644
index 0000000..4d33888
--- /dev/null
+++ b/test/const-init.c
@@ -0,0 +1 @@
+const struct {struct {int x, y;} t;} s = {{{1}, 2}};
diff --git a/test/const-init.qbe b/test/const-init.qbe
new file mode 100644
index 0000000..fb5d305
--- /dev/null
+++ b/test/const-init.qbe
@@ -0,0 +1 @@
+export data $s = align 4 { w 1, w 2, }
diff --git a/test/escaped-newline.c b/test/escaped-newline.c
new file mode 100644
index 0000000..d659179
--- /dev/null
+++ b/test/escaped-newline.c
@@ -0,0 +1,2 @@
+int split\
+ident = 3;
diff --git a/test/escaped-newline.qbe b/test/escaped-newline.qbe
new file mode 100644
index 0000000..cd2b5bf
--- /dev/null
+++ b/test/escaped-newline.qbe
@@ -0,0 +1 @@
+export data $splitident = align 4 { w 3, }
diff --git a/test/float-const-leading-dot.c b/test/float-const-leading-dot.c
new file mode 100644
index 0000000..bfed54a
--- /dev/null
+++ b/test/float-const-leading-dot.c
@@ -0,0 +1 @@
+float x = .5;
diff --git a/test/float-const-leading-dot.qbe b/test/float-const-leading-dot.qbe
new file mode 100644
index 0000000..12ae325
--- /dev/null
+++ b/test/float-const-leading-dot.qbe
@@ -0,0 +1 @@
+export data $x = align 4 { s s_0x1p-1, }
diff --git a/test/float-promote.c b/test/float-promote.c
new file mode 100644
index 0000000..572719a
--- /dev/null
+++ b/test/float-promote.c
@@ -0,0 +1,8 @@
+void g1();
+void g2(int, ...);
+void g3(float);
+void f(void) {
+ g1(1.0f);
+ g2(0, 1.0f);
+ g3(1.0f);
+}
diff --git a/test/float-promote.qbe b/test/float-promote.qbe
new file mode 100644
index 0000000..052b1fa
--- /dev/null
+++ b/test/float-promote.qbe
@@ -0,0 +1,11 @@
+export
+function $f() {
+@start.1
+@body.2
+ %.1 =d exts s_0x1p+0
+ call $g1(d %.1)
+ %.2 =d exts s_0x1p+0
+ call $g2(w 0, d %.2, ...)
+ call $g3(s s_0x1p+0)
+ ret
+}
diff --git a/test/float-to-uint32.c b/test/float-to-uint32.c
new file mode 100644
index 0000000..a82c89d
--- /dev/null
+++ b/test/float-to-uint32.c
@@ -0,0 +1,4 @@
+float g(void);
+unsigned f(void) {
+ return g();
+}
diff --git a/test/float-to-uint32.qbe b/test/float-to-uint32.qbe
new file mode 100644
index 0000000..a8463f3
--- /dev/null
+++ b/test/float-to-uint32.qbe
@@ -0,0 +1,9 @@
+export
+function w $f() {
+@start.1
+@body.2
+ %.1 =s call $g()
+ %.2 =l stosi %.1
+ %.3 =w copy %.2
+ ret %.3
+}
diff --git a/test/float-to-uint64.c b/test/float-to-uint64.c
new file mode 100644
index 0000000..10e7809
--- /dev/null
+++ b/test/float-to-uint64.c
@@ -0,0 +1,4 @@
+float g(void);
+unsigned long long f(void) {
+ return g();
+}
diff --git a/test/float-to-uint64.qbe b/test/float-to-uint64.qbe
new file mode 100644
index 0000000..3c3aa01
--- /dev/null
+++ b/test/float-to-uint64.qbe
@@ -0,0 +1,18 @@
+export
+function l $f() {
+@start.1
+@body.2
+ %.1 =s call $g()
+ %.2 =w cges %.1, s_0x1p+63
+ jnz %.2, @ftou_big.4, @ftou_small.3
+@ftou_small.3
+ %.3 =l stosi %.1
+ jmp @ftou_join.5
+@ftou_big.4
+ %.4 =s sub %.1, s_0x1p+63
+ %.5 =l stosi %.4
+ %.6 =l xor %.5, 9223372036854775808
+@ftou_join.5
+ %.7 =l phi @ftou_small.3 %.3, @ftou_big.4 %.6
+ ret %.7
+}
diff --git a/test/for-loop.c b/test/for-loop.c
new file mode 100644
index 0000000..ea769c5
--- /dev/null
+++ b/test/for-loop.c
@@ -0,0 +1,6 @@
+void g(int);
+void f(void) {
+ int i;
+ for (i = 0; i < 10; ++i)
+ g(i);
+}
diff --git a/test/for-loop.qbe b/test/for-loop.qbe
new file mode 100644
index 0000000..56b38b1
--- /dev/null
+++ b/test/for-loop.qbe
@@ -0,0 +1,21 @@
+export
+function $f() {
+@start.1
+ %.1 =l alloc4 4
+@body.2
+ storew 0, %.1
+@for_cond.3
+ %.2 =w loadsw %.1
+ %.3 =w csltw %.2, 10
+ jnz %.3, @for_body.4, @for_join.6
+@for_body.4
+ %.4 =w loadsw %.1
+ call $g(w %.4)
+@for_cont.5
+ %.5 =w loadsw %.1
+ %.6 =w add %.5, 1
+ storew %.6, %.1
+ jmp @for_cond.3
+@for_join.6
+ ret
+}
diff --git a/test/global-align.c b/test/global-align.c
new file mode 100644
index 0000000..9d35d91
--- /dev/null
+++ b/test/global-align.c
@@ -0,0 +1 @@
+_Alignas(8) char c;
diff --git a/test/global-align.qbe b/test/global-align.qbe
new file mode 100644
index 0000000..1b833ed
--- /dev/null
+++ b/test/global-align.qbe
@@ -0,0 +1 @@
+export data $c = align 8 { z 1 }
diff --git a/test/hello.c b/test/hello.c
new file mode 100644
index 0000000..bad06bc
--- /dev/null
+++ b/test/hello.c
@@ -0,0 +1,5 @@
+int puts(const char *);
+int main(void) {
+ puts("hello");
+ return 0;
+}
diff --git a/test/hello.qbe b/test/hello.qbe
new file mode 100644
index 0000000..3e695ab
--- /dev/null
+++ b/test/hello.qbe
@@ -0,0 +1,9 @@
+data $.Lstring.2 = align 1 { b "hello", z 1, }
+export
+function w $main() {
+@start.1
+@body.2
+ %.1 =l copy $.Lstring.2
+ %.2 =w call $puts(l %.1)
+ ret 0
+}
diff --git a/test/initializer-long-string.c b/test/initializer-long-string.c
new file mode 100644
index 0000000..4de06d4
--- /dev/null
+++ b/test/initializer-long-string.c
@@ -0,0 +1 @@
+char s[4] = "hello";
diff --git a/test/initializer-long-string.qbe b/test/initializer-long-string.qbe
new file mode 100644
index 0000000..3aa2f6f
--- /dev/null
+++ b/test/initializer-long-string.qbe
@@ -0,0 +1 @@
+export data $s = align 1 { b "hell", }
diff --git a/test/initializer-nested-array-address.c b/test/initializer-nested-array-address.c
new file mode 100644
index 0000000..fb8bbd5
--- /dev/null
+++ b/test/initializer-nested-array-address.c
@@ -0,0 +1,2 @@
+int x[2][3];
+int *y = &x[1][2];
diff --git a/test/initializer-nested-array-address.qbe b/test/initializer-nested-array-address.qbe
new file mode 100644
index 0000000..5379590
--- /dev/null
+++ b/test/initializer-nested-array-address.qbe
@@ -0,0 +1,2 @@
+export data $y = align 8 { l $x + 20, }
+export data $x = align 4 { z 24 }
diff --git a/test/initializer-replace-local.c b/test/initializer-replace-local.c
new file mode 100644
index 0000000..8b93ef2
--- /dev/null
+++ b/test/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/test/initializer-replace-local.qbe b/test/initializer-replace-local.qbe
new file mode 100644
index 0000000..72ad90a
--- /dev/null
+++ b/test/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/test/initializer-replace-static.c b/test/initializer-replace-static.c
new file mode 100644
index 0000000..c1fa376
--- /dev/null
+++ b/test/initializer-replace-static.c
@@ -0,0 +1,6 @@
+struct {
+ char s[6];
+} x = {
+ .s = "hello",
+ .s[1] = 'a',
+};
diff --git a/test/initializer-replace-static.qbe b/test/initializer-replace-static.qbe
new file mode 100644
index 0000000..18b774e
--- /dev/null
+++ b/test/initializer-replace-static.qbe
@@ -0,0 +1 @@
+export data $x = align 1 { b "hallo", z 1, }
diff --git a/test/initializer-short-string.c b/test/initializer-short-string.c
new file mode 100644
index 0000000..32e2aec
--- /dev/null
+++ b/test/initializer-short-string.c
@@ -0,0 +1,3 @@
+void f(void) {
+ char s[10] = "abc";
+}
diff --git a/test/initializer-short-string.qbe b/test/initializer-short-string.qbe
new file mode 100644
index 0000000..5b95ea1
--- /dev/null
+++ b/test/initializer-short-string.qbe
@@ -0,0 +1,27 @@
+export
+function $f() {
+@start.1
+ %.1 =l alloc4 10
+@body.2
+ %.2 =l add %.1, 0
+ storeb 97, %.2
+ %.3 =l add %.1, 1
+ storeb 98, %.3
+ %.4 =l add %.1, 2
+ storeb 99, %.4
+ %.5 =l add %.1, 3
+ storeb 0, %.5
+ %.6 =l add %.1, 4
+ storeb 0, %.6
+ %.7 =l add %.1, 5
+ storeb 0, %.7
+ %.8 =l add %.1, 6
+ storeb 0, %.8
+ %.9 =l add %.1, 7
+ storeb 0, %.9
+ %.10 =l add %.1, 8
+ storeb 0, %.10
+ %.11 =l add %.1, 9
+ storeb 0, %.11
+ ret
+}
diff --git a/test/initializer-string-array.c b/test/initializer-string-array.c
new file mode 100644
index 0000000..9ccc9d0
--- /dev/null
+++ b/test/initializer-string-array.c
@@ -0,0 +1,3 @@
+void f(void) {
+ char x[][4] = {"abc", "xyz"};
+}
diff --git a/test/initializer-string-array.qbe b/test/initializer-string-array.qbe
new file mode 100644
index 0000000..87a03fd
--- /dev/null
+++ b/test/initializer-string-array.qbe
@@ -0,0 +1,23 @@
+export
+function $f() {
+@start.1
+ %.1 =l alloc4 8
+@body.2
+ %.2 =l add %.1, 0
+ storeb 97, %.2
+ %.3 =l add %.1, 1
+ storeb 98, %.3
+ %.4 =l add %.1, 2
+ storeb 99, %.4
+ %.5 =l add %.1, 3
+ storeb 0, %.5
+ %.6 =l add %.1, 4
+ storeb 120, %.6
+ %.7 =l add %.1, 5
+ storeb 121, %.7
+ %.8 =l add %.1, 6
+ storeb 122, %.8
+ %.9 =l add %.1, 7
+ storeb 0, %.9
+ ret
+}
diff --git a/test/initializer-string.c b/test/initializer-string.c
new file mode 100644
index 0000000..c92f897
--- /dev/null
+++ b/test/initializer-string.c
@@ -0,0 +1,4 @@
+char x[] = "hello";
+void f(void) {
+ char y[] = "hello";
+}
diff --git a/test/initializer-string.qbe b/test/initializer-string.qbe
new file mode 100644
index 0000000..ba992da
--- /dev/null
+++ b/test/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
+}
diff --git a/test/initializer-unsigned-string.c b/test/initializer-unsigned-string.c
new file mode 100644
index 0000000..a932889
--- /dev/null
+++ b/test/initializer-unsigned-string.c
@@ -0,0 +1 @@
+unsigned char s[] = "abc";
diff --git a/test/initializer-unsigned-string.qbe b/test/initializer-unsigned-string.qbe
new file mode 100644
index 0000000..46be123
--- /dev/null
+++ b/test/initializer-unsigned-string.qbe
@@ -0,0 +1 @@
+export data $s = align 1 { b "abc", z 1, }
diff --git a/test/label-typedef.c b/test/label-typedef.c
new file mode 100644
index 0000000..f3744e3
--- /dev/null
+++ b/test/label-typedef.c
@@ -0,0 +1,4 @@
+typedef int x;
+void f(void) {
+x:;
+}
diff --git a/test/label-typedef.qbe b/test/label-typedef.qbe
new file mode 100644
index 0000000..b11f621
--- /dev/null
+++ b/test/label-typedef.qbe
@@ -0,0 +1,7 @@
+export
+function $f() {
+@start.1
+@body.2
+@x.3
+ ret
+}
diff --git a/test/local-align.c b/test/local-align.c
new file mode 100644
index 0000000..8fc3736
--- /dev/null
+++ b/test/local-align.c
@@ -0,0 +1,3 @@
+void f(void) {
+ _Alignas(16) char x[4];
+}
diff --git a/test/local-align.qbe b/test/local-align.qbe
new file mode 100644
index 0000000..bc3b85c
--- /dev/null
+++ b/test/local-align.qbe
@@ -0,0 +1,7 @@
+export
+function $f() {
+@start.1
+ %.1 =l alloc16 4
+@body.2
+ ret
+}
diff --git a/test/local-init.c b/test/local-init.c
new file mode 100644
index 0000000..0e886d7
--- /dev/null
+++ b/test/local-init.c
@@ -0,0 +1,6 @@
+void f(void) {
+ struct {
+ char c[8];
+ long long i[3];
+ } s = {'a'};
+}
diff --git a/test/local-init.qbe b/test/local-init.qbe
new file mode 100644
index 0000000..8d7346a
--- /dev/null
+++ b/test/local-init.qbe
@@ -0,0 +1,22 @@
+export
+function $f() {
+@start.1
+ %.1 =l alloc8 32
+@body.2
+ %.2 =l add %.1, 0
+ %.3 =w copy 97
+ storeb %.3, %.2
+ %.4 =l add %.1, 1
+ storeb 0, %.4
+ %.5 =l add %.1, 2
+ storeh 0, %.5
+ %.6 =l add %.1, 4
+ storew 0, %.6
+ %.7 =l add %.1, 8
+ storel 0, %.7
+ %.8 =l add %.1, 16
+ storel 0, %.8
+ %.9 =l add %.1, 24
+ storel 0, %.9
+ ret
+}
diff --git a/test/lvalue-conversion.c b/test/lvalue-conversion.c
new file mode 100644
index 0000000..6bbc326
--- /dev/null
+++ b/test/lvalue-conversion.c
@@ -0,0 +1,6 @@
+void g();
+void f(void) {
+ static const unsigned char c = 0;
+ g(c);
+ g(~c);
+}
diff --git a/test/lvalue-conversion.qbe b/test/lvalue-conversion.qbe
new file mode 100644
index 0000000..ac5fbc3
--- /dev/null
+++ b/test/lvalue-conversion.qbe
@@ -0,0 +1,14 @@
+data $.Lc.2 = align 1 { b 0, }
+export
+function $f() {
+@start.1
+@body.2
+ %.1 =w loadub $.Lc.2
+ %.2 =w extub %.1
+ call $g(w %.2)
+ %.3 =w loadub $.Lc.2
+ %.4 =w extub %.3
+ %.5 =w xor %.4, 18446744073709551615
+ call $g(w %.5)
+ ret
+}
diff --git a/test/nested-array.c b/test/nested-array.c
new file mode 100644
index 0000000..0f0a121
--- /dev/null
+++ b/test/nested-array.c
@@ -0,0 +1 @@
+int x[2][3];
diff --git a/test/nested-array.qbe b/test/nested-array.qbe
new file mode 100644
index 0000000..cfc6bed
--- /dev/null
+++ b/test/nested-array.qbe
@@ -0,0 +1 @@
+export data $x = align 4 { z 24 }
diff --git a/test/sizeof-compound-literal.c b/test/sizeof-compound-literal.c
new file mode 100644
index 0000000..b25d06a
--- /dev/null
+++ b/test/sizeof-compound-literal.c
@@ -0,0 +1 @@
+int x = sizeof (int){1};
diff --git a/test/sizeof-compound-literal.qbe b/test/sizeof-compound-literal.qbe
new file mode 100644
index 0000000..23be3d8
--- /dev/null
+++ b/test/sizeof-compound-literal.qbe
@@ -0,0 +1 @@
+export data $x = align 4 { w 4, }
diff --git a/test/sizeof-postfix.c b/test/sizeof-postfix.c
new file mode 100644
index 0000000..9062517
--- /dev/null
+++ b/test/sizeof-postfix.c
@@ -0,0 +1,4 @@
+int x;
+int f(void) {
+ return sizeof (x)++;
+}
diff --git a/test/sizeof-postfix.qbe b/test/sizeof-postfix.qbe
new file mode 100644
index 0000000..d9eedd8
--- /dev/null
+++ b/test/sizeof-postfix.qbe
@@ -0,0 +1,8 @@
+export
+function w $f() {
+@start.1
+@body.2
+ %.1 =w copy 4
+ ret %.1
+}
+export data $x = align 4 { z 4 }
diff --git a/test/struct-copy.c b/test/struct-copy.c
new file mode 100644
index 0000000..33084aa
--- /dev/null
+++ b/test/struct-copy.c
@@ -0,0 +1,8 @@
+struct s {
+ char s[5];
+ float f;
+} x;
+
+void f(void) {
+ struct s y = x;
+}
diff --git a/test/struct-copy.qbe b/test/struct-copy.qbe
new file mode 100644
index 0000000..4778921
--- /dev/null
+++ b/test/struct-copy.qbe
@@ -0,0 +1,21 @@
+export
+function $f() {
+@start.1
+ %.1 =l alloc4 12
+@body.2
+ %.2 =l add %.1, 0
+ %.3 =l loaduw $x
+ storew %.3, %.2
+ %.4 =l add $x, 4
+ %.5 =l add %.2, 4
+ %.6 =l loaduw %.4
+ storew %.6, %.5
+ %.7 =l add %.4, 4
+ %.8 =l add %.5, 4
+ %.9 =l loaduw %.7
+ storew %.9, %.8
+ %.10 =l add %.7, 4
+ %.11 =l add %.8, 4
+ ret
+}
+export data $x = align 4 { z 12 }
diff --git a/test/struct-passing.c b/test/struct-passing.c
new file mode 100644
index 0000000..54c65a2
--- /dev/null
+++ b/test/struct-passing.c
@@ -0,0 +1,11 @@
+struct s {
+ int x;
+ struct {
+ char y[3];
+ short z;
+ } s[2];
+ double w;
+};
+
+void f(struct s s) {
+}
diff --git a/test/struct-passing.qbe b/test/struct-passing.qbe
new file mode 100644
index 0000000..07bd483
--- /dev/null
+++ b/test/struct-passing.qbe
@@ -0,0 +1,8 @@
+type :.2 = { b 3, h, }
+type :s.1 = { w, :.2 2, d, }
+export
+function $f(:s.1 %.1) {
+@start.1
+@body.2
+ ret
+}
diff --git a/test/struct-return-1.c b/test/struct-return-1.c
new file mode 100644
index 0000000..e1631a8
--- /dev/null
+++ b/test/struct-return-1.c
@@ -0,0 +1,3 @@
+struct s {int x;} f(void) {
+ return (struct s){2};
+}
diff --git a/test/struct-return-1.qbe b/test/struct-return-1.qbe
new file mode 100644
index 0000000..fcdf699
--- /dev/null
+++ b/test/struct-return-1.qbe
@@ -0,0 +1,10 @@
+type :s.1 = { w, }
+export
+function :s.1 $f() {
+@start.1
+ %.1 =l alloc4 4
+@body.2
+ %.2 =l add %.1, 0
+ storew 2, %.2
+ ret %.1
+}
diff --git a/test/struct-return-2.c b/test/struct-return-2.c
new file mode 100644
index 0000000..726e667
--- /dev/null
+++ b/test/struct-return-2.c
@@ -0,0 +1,4 @@
+struct {int x, y;} g(void);
+int f(void) {
+ return g().y;
+}
diff --git a/test/struct-return-2.qbe b/test/struct-return-2.qbe
new file mode 100644
index 0000000..415ec2f
--- /dev/null
+++ b/test/struct-return-2.qbe
@@ -0,0 +1,14 @@
+type :.1 = { w, w, }
+export
+function w $f() {
+@start.1
+@body.2
+ %.1 =:.1 call $g()
+ %.2 =l copy %.1
+ %.3 =l copy %.2
+ %.4 =l mul 4, 1
+ %.5 =l add %.3, %.4
+ %.6 =l copy %.5
+ %.7 =w loadsw %.6
+ ret %.7
+}
diff --git a/test/subtract-pointer.c b/test/subtract-pointer.c
new file mode 100644
index 0000000..1de9dde
--- /dev/null
+++ b/test/subtract-pointer.c
@@ -0,0 +1,3 @@
+void f(int *x, int *y) {
+ x - y;
+}
diff --git a/test/subtract-pointer.qbe b/test/subtract-pointer.qbe
new file mode 100644
index 0000000..0e7e9a3
--- /dev/null
+++ b/test/subtract-pointer.qbe
@@ -0,0 +1,16 @@
+export
+function $f(l %.1, l %.3) {
+@start.1
+ %.2 =l alloc8 8
+ storel %.1, %.2
+ %.4 =l alloc8 8
+ storel %.3, %.4
+@body.2
+ %.5 =l loadl %.2
+ %.6 =l copy %.5
+ %.7 =l loadl %.4
+ %.8 =l copy %.7
+ %.9 =l sub %.6, %.8
+ %.10 =l div %.9, 4
+ ret
+}
diff --git a/test/switch.c b/test/switch.c
new file mode 100644
index 0000000..b1b7733
--- /dev/null
+++ b/test/switch.c
@@ -0,0 +1,10 @@
+void f(void) {
+ switch (0) {
+ case 3: break;
+ case 52: break;
+ case -3: break;
+ default: break;
+ case 0: break;
+ case 101: break;
+ }
+}
diff --git a/test/switch.qbe b/test/switch.qbe
new file mode 100644
index 0000000..bb69c15
--- /dev/null
+++ b/test/switch.qbe
@@ -0,0 +1,62 @@
+export
+function $f() {
+@start.1
+@body.2
+ jmp @switch_cond.3
+@switch_case.5
+ jmp @switch_join.4
+@switch_case.6
+ jmp @switch_join.4
+@switch_case.7
+ jmp @switch_join.4
+@switch_default.8
+ jmp @switch_join.4
+@switch_case.9
+ jmp @switch_join.4
+@switch_case.10
+ jmp @switch_join.4
+@switch_cond.3
+ %.1 =w ceqw 0, 52
+ jnz %.1, @switch_case.6, @switch_ne.11
+@switch_ne.11
+ %.2 =w cultw 0, 52
+ jnz %.2, @switch_lt.12, @switch_gt.13
+@switch_lt.12
+ %.3 =w ceqw 0, 3
+ jnz %.3, @switch_case.5, @switch_ne.14
+@switch_ne.14
+ %.4 =w cultw 0, 3
+ jnz %.4, @switch_lt.15, @switch_gt.16
+@switch_lt.15
+ %.5 =w ceqw 0, 0
+ jnz %.5, @switch_case.9, @switch_ne.17
+@switch_ne.17
+ %.6 =w cultw 0, 0
+ jnz %.6, @switch_lt.18, @switch_gt.19
+@switch_lt.18
+ jmp @switch_default.8
+@switch_gt.19
+ jmp @switch_default.8
+@switch_gt.16
+ jmp @switch_default.8
+@switch_gt.13
+ %.7 =w ceqw 0, 18446744073709551613
+ jnz %.7, @switch_case.7, @switch_ne.20
+@switch_ne.20
+ %.8 =w cultw 0, 18446744073709551613
+ jnz %.8, @switch_lt.21, @switch_gt.22
+@switch_lt.21
+ %.9 =w ceqw 0, 101
+ jnz %.9, @switch_case.10, @switch_ne.23
+@switch_ne.23
+ %.10 =w cultw 0, 101
+ jnz %.10, @switch_lt.24, @switch_gt.25
+@switch_lt.24
+ jmp @switch_default.8
+@switch_gt.25
+ jmp @switch_default.8
+@switch_gt.22
+ jmp @switch_default.8
+@switch_join.4
+ ret
+}
diff --git a/test/tentative.c b/test/tentative.c
new file mode 100644
index 0000000..1f484ae
--- /dev/null
+++ b/test/tentative.c
@@ -0,0 +1,2 @@
+int x;
+int x = 5;
diff --git a/test/tentative.qbe b/test/tentative.qbe
new file mode 100644
index 0000000..bf252fd
--- /dev/null
+++ b/test/tentative.qbe
@@ -0,0 +1 @@
+export data $x = align 4 { w 5, }
diff --git a/test/typedef-name.c b/test/typedef-name.c
new file mode 100644
index 0000000..ab85460
--- /dev/null
+++ b/test/typedef-name.c
@@ -0,0 +1,4 @@
+typedef int x;
+void f(void) {
+ long x;
+}
diff --git a/test/typedef-name.qbe b/test/typedef-name.qbe
new file mode 100644
index 0000000..5ce995e
--- /dev/null
+++ b/test/typedef-name.qbe
@@ -0,0 +1,7 @@
+export
+function $f() {
+@start.1
+ %.1 =l alloc8 8
+@body.2
+ ret
+}
diff --git a/test/typedef.c b/test/typedef.c
new file mode 100644
index 0000000..763d37d
--- /dev/null
+++ b/test/typedef.c
@@ -0,0 +1,2 @@
+typedef int T;
+T x;
diff --git a/test/typedef.qbe b/test/typedef.qbe
new file mode 100644
index 0000000..7cf0e40
--- /dev/null
+++ b/test/typedef.qbe
@@ -0,0 +1 @@
+export data $x = align 4 { z 4 }
diff --git a/test/typeof.c b/test/typeof.c
new file mode 100644
index 0000000..d6a218f
--- /dev/null
+++ b/test/typeof.c
@@ -0,0 +1,20 @@
+int v;
+typedef int* t;
+int f() {v = 1; return 0;}
+int main() {
+ __typeof__(f()) x = 123;
+ __typeof__(t) y = &x;
+
+ if (x != 123)
+ return 1;
+ if (*y != 123)
+ return 2;
+ if (sizeof(y) != sizeof(int*))
+ return 3;
+ if (sizeof(x) != sizeof(int))
+ return 4;
+ if (v != 0)
+ return 5;
+
+ return 0;
+}
diff --git a/test/typeof.qbe b/test/typeof.qbe
new file mode 100644
index 0000000..5cd138f
--- /dev/null
+++ b/test/typeof.qbe
@@ -0,0 +1,54 @@
+export
+function w $f() {
+@start.1
+@body.2
+ storew 1, $v
+ ret 0
+}
+export
+function w $main() {
+@start.3
+ %.1 =l alloc4 4
+ %.3 =l alloc8 8
+@body.4
+ %.2 =l add %.1, 0
+ storew 123, %.2
+ %.4 =l add %.3, 0
+ storel %.1, %.4
+ %.5 =w loadsw %.1
+ %.6 =w cnew %.5, 123
+ %.7 =w cnew %.6, 0
+ jnz %.7, @if_true.5, @if_false.6
+@if_true.5
+ ret 1
+@if_false.6
+ %.8 =l loadl %.3
+ %.9 =w loadsw %.8
+ %.10 =w cnew %.9, 123
+ %.11 =w cnew %.10, 0
+ jnz %.11, @if_true.7, @if_false.8
+@if_true.7
+ ret 2
+@if_false.8
+ %.12 =w cnel 8, 8
+ %.13 =w cnew %.12, 0
+ jnz %.13, @if_true.9, @if_false.10
+@if_true.9
+ ret 3
+@if_false.10
+ %.14 =w cnel 4, 4
+ %.15 =w cnew %.14, 0
+ jnz %.15, @if_true.11, @if_false.12
+@if_true.11
+ ret 4
+@if_false.12
+ %.16 =w loadsw $v
+ %.17 =w cnew %.16, 0
+ %.18 =w cnew %.17, 0
+ jnz %.18, @if_true.13, @if_false.14
+@if_true.13
+ ret 5
+@if_false.14
+ ret 0
+}
+export data $v = align 4 { z 4 }
diff --git a/test/uint32-to-float.c b/test/uint32-to-float.c
new file mode 100644
index 0000000..0a045be
--- /dev/null
+++ b/test/uint32-to-float.c
@@ -0,0 +1,4 @@
+unsigned g(void);
+float f(void) {
+ return g();
+}
diff --git a/test/uint32-to-float.qbe b/test/uint32-to-float.qbe
new file mode 100644
index 0000000..0e90531
--- /dev/null
+++ b/test/uint32-to-float.qbe
@@ -0,0 +1,9 @@
+export
+function s $f() {
+@start.1
+@body.2
+ %.1 =w call $g()
+ %.2 =l extuw %.1
+ %.3 =s sltof %.2
+ ret %.3
+}
diff --git a/test/uint64-to-float.c b/test/uint64-to-float.c
new file mode 100644
index 0000000..b4e7fc6
--- /dev/null
+++ b/test/uint64-to-float.c
@@ -0,0 +1,4 @@
+unsigned long long g(void);
+float f(void) {
+ return g();
+}
diff --git a/test/uint64-to-float.qbe b/test/uint64-to-float.qbe
new file mode 100644
index 0000000..6542c29
--- /dev/null
+++ b/test/uint64-to-float.qbe
@@ -0,0 +1,20 @@
+export
+function s $f() {
+@start.1
+@body.2
+ %.1 =l call $g()
+ %.2 =w csltl %.1, 0
+ jnz %.2, @utof_big.4, @utof_small.3
+@utof_small.3
+ %.3 =s sltof %.1
+ jmp @utof_join.5
+@utof_big.4
+ %.4 =l and %.1, 1
+ %.5 =l shr %.1, 1
+ %.6 =l or %.5, %.4
+ %.7 =s sltof %.6
+ %.8 =s add %.7, %.7
+@utof_join.5
+ %.9 =s phi @utof_small.3 %.3, @utof_big.4 %.8
+ ret %.9
+}
diff --git a/test/union-passing.c b/test/union-passing.c
new file mode 100644
index 0000000..ddf35f2
--- /dev/null
+++ b/test/union-passing.c
@@ -0,0 +1,2 @@
+void f(union {int x; float y;} u) {
+}
diff --git a/test/union-passing.qbe b/test/union-passing.qbe
new file mode 100644
index 0000000..2edd8db
--- /dev/null
+++ b/test/union-passing.qbe
@@ -0,0 +1,7 @@
+type :.1 = { { w } { s } }
+export
+function $f(:.1 %.1) {
+@start.1
+@body.2
+ ret
+}
diff --git a/test/union.c b/test/union.c
new file mode 100644
index 0000000..9b4e5f9
--- /dev/null
+++ b/test/union.c
@@ -0,0 +1,4 @@
+union {
+ int x;
+ double y;
+} a = {.x = 5}, b = {.y = 7.5};
diff --git a/test/union.qbe b/test/union.qbe
new file mode 100644
index 0000000..adbda57
--- /dev/null
+++ b/test/union.qbe
@@ -0,0 +1,2 @@
+export data $a = align 8 { w 5, z 4 }
+export data $b = align 8 { d d_0x1.ep+2, }
diff --git a/test/unused-return.c b/test/unused-return.c
new file mode 100644
index 0000000..815fcb1
--- /dev/null
+++ b/test/unused-return.c
@@ -0,0 +1,4 @@
+int g(void);
+void f(void) {
+ g();
+}
diff --git a/test/unused-return.qbe b/test/unused-return.qbe
new file mode 100644
index 0000000..d269c7f
--- /dev/null
+++ b/test/unused-return.qbe
@@ -0,0 +1,7 @@
+export
+function $f() {
+@start.1
+@body.2
+ %.1 =w call $g()
+ ret
+}
diff --git a/test/varargs.c b/test/varargs.c
new file mode 100644
index 0000000..0b5a73d
--- /dev/null
+++ b/test/varargs.c
@@ -0,0 +1,12 @@
+void f(int n, ...) {
+ __builtin_va_list ap;
+
+ __builtin_va_start(ap, n);
+ while (n) {
+ __builtin_va_arg(ap, int);
+ __builtin_va_arg(ap, float);
+ __builtin_va_arg(ap, char *);
+ --n;
+ }
+ __builtin_va_end(ap);
+}
diff --git a/test/varargs.qbe b/test/varargs.qbe
new file mode 100644
index 0000000..16db877
--- /dev/null
+++ b/test/varargs.qbe
@@ -0,0 +1,22 @@
+export
+function $f(w %.1, ...) {
+@start.1
+ %.2 =l alloc4 4
+ storew %.1, %.2
+ %.3 =l alloc8 24
+@body.2
+ vastart %.3
+@while_cond.3
+ %.4 =w loadsw %.2
+ jnz %.4, @while_body.4, @while_join.5
+@while_body.4
+ %.5 =w vaarg %.3
+ %.6 =s vaarg %.3
+ %.7 =l vaarg %.3
+ %.8 =w loadsw %.2
+ %.9 =w sub %.8, 1
+ storew %.9, %.2
+ jmp @while_cond.3
+@while_join.5
+ ret
+}