diff options
author | Xavier Leroy <xavier.leroy@inria.fr> | 2015-04-28 11:21:59 +0200 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@inria.fr> | 2015-04-28 11:21:59 +0200 |
commit | b04bb783badb9051c62b26fb1858f916d0e4ccd0 (patch) | |
tree | c102a6ccdcfad8b4b3a76cffc2019742232a7cb3 /test/regression/bitfields9.c | |
parent | 3c6f5343e0e64b273658b6b3508a8dd6c29b8cef (diff) | |
download | compcert-b04bb783badb9051c62b26fb1858f916d0e4ccd0.tar.gz compcert-b04bb783badb9051c62b26fb1858f916d0e4ccd0.zip |
Extended inline asm: handle missing cases.
Bitfields: better translation of initializers and compound literals; run this pass before unblocking.
Transform.stmt: extend with ability to treat unblocked code.
test/regression: more bitfield tests.
Diffstat (limited to 'test/regression/bitfields9.c')
-rw-r--r-- | test/regression/bitfields9.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/test/regression/bitfields9.c b/test/regression/bitfields9.c new file mode 100644 index 00000000..b33c4064 --- /dev/null +++ b/test/regression/bitfields9.c @@ -0,0 +1,49 @@ +#include <stdio.h> + +/* Initialization of bit-fields */ + +struct s { + signed char a: 6; + unsigned int b: 2; +}; + +struct t { + unsigned int c: 16; + unsigned int d: 1; + short e: 8; +}; + +void print_s(char * msg, struct s p) +{ + printf("%s = { a = %d, b = %d }\n", msg, p.a, p.b); +} + +void print_t(char * msg, struct t p) +{ + printf("%s = { c = %d, d = %d, e = %d }\n", msg, p.c, p.d, p.e); +} + +/* Global initialization */ +struct s glob_s = { -12, 1 }; +struct t glob_t = { 123, 0, -45 }; + +/* Local initialization */ +void f(int x, int y) +{ + struct s loc_s = { x, y }; + struct t loc_t = { x, 1, y }; + print_s("loc_s", loc_s); + print_t("loc_t", loc_t); + print_s("compound_s", (struct s) { y, x }); + print_t("compound_t", (struct t) { y, 0, -x }); +} + +int main() +{ + print_s("glob_s", glob_s); + print_t("glob_t", glob_t); + f(11, 2); + f(7, 50); + return 0; +} + |