diff options
author | xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e> | 2010-04-07 08:31:55 +0000 |
---|---|---|
committer | xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e> | 2010-04-07 08:31:55 +0000 |
commit | b66aaf2d1b90ff51f54bcd2a344a6ab50ac6fe86 (patch) | |
tree | 4ffb86b56c032aeca0f2cf031d8ebba64535b4d6 /test/regression/bitfields2.c | |
parent | 3c7507976d81da3ccafc6efb06facbff0e0c7fa2 (diff) |
Static initialization of structs with bitfields
git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@1311 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
Diffstat (limited to 'test/regression/bitfields2.c')
-rw-r--r-- | test/regression/bitfields2.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/regression/bitfields2.c b/test/regression/bitfields2.c new file mode 100644 index 0000000..b555f1e --- /dev/null +++ b/test/regression/bitfields2.c @@ -0,0 +1,32 @@ +#include <stdio.h> + +struct s { + signed char a: 6; + unsigned int b: 2; +}; + +struct t { + unsigned int c: 16; + unsigned int d: 1; + short e: 8; +}; + +struct u { + unsigned int f: 18; + unsigned int g: 24; + char h; +}; + +struct s x = { 1, 2 }; + +struct t y = { 3, 4, 5 }; + +struct u z = { 6, 7, 8 }; + +int main() +{ + printf("x = { a = %d, b = %d }\n", x.a, x.b); + printf("y = { c = %d, d = %d; e = %d }\n", y.c, y.d, y.e); + printf("z = { f = %d, g = %d; h = %d }\n", z.f, z.g, z.h); +} + |