diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/struct-packed.c | 9 | ||||
-rw-r--r-- | test/struct-packed.qbe | 17 |
2 files changed, 26 insertions, 0 deletions
diff --git a/test/struct-packed.c b/test/struct-packed.c new file mode 100644 index 0000000..d05bf91 --- /dev/null +++ b/test/struct-packed.c @@ -0,0 +1,9 @@ +struct [[gnu::packed]] { + char a; + long long b; + short c; +} s = {1, 2, 3}; + +int main(void) { + return s.a + s.b - s.c; +} diff --git a/test/struct-packed.qbe b/test/struct-packed.qbe new file mode 100644 index 0000000..ee79301 --- /dev/null +++ b/test/struct-packed.qbe @@ -0,0 +1,17 @@ +export data $s = align 1 { b 1, l 2, h 3, } +export +function w $main() { +@start.1 +@body.2 + %.1 =l add $s, 0 + %.2 =w loadsb %.1 + %.3 =l extsb %.2 + %.4 =l add $s, 1 + %.5 =l loadl %.4 + %.6 =l add %.3, %.5 + %.7 =l add $s, 9 + %.8 =w loadsh %.7 + %.9 =l extsh %.8 + %.10 =l sub %.6, %.9 + ret %.10 +} |