From a15858a0a8fcea82db02fe8c9bd2ed912210419f Mon Sep 17 00:00:00 2001 From: xleroy Date: Wed, 18 Aug 2010 09:06:55 +0000 Subject: Merge of branches/full-expr-4: - Csyntax, Csem: source C language has side-effects within expressions, performs implicit casts, and has nondeterministic reduction semantics for expressions - Cstrategy: deterministic red. sem. for the above - Clight: the previous source C language, with pure expressions. Added: temporary variables + implicit casts. - New pass SimplExpr to pull side-effects out of expressions (previously done in untrusted Caml code in cparser/) - Csharpminor: added temporary variables to match Clight. - Cminorgen: adapted, removed cast optimization (moved to back-end) - CastOptim: RTL-level optimization of casts - cparser: transformations Bitfields, StructByValue and StructAssign now work on non-simplified expressions - Added pretty-printers for several intermediate languages, and matching -dxxx command-line flags. git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@1467 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e --- test/regression/bitfields4.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 test/regression/bitfields4.c (limited to 'test/regression/bitfields4.c') diff --git a/test/regression/bitfields4.c b/test/regression/bitfields4.c new file mode 100644 index 00000000..6333e6d9 --- /dev/null +++ b/test/regression/bitfields4.c @@ -0,0 +1,39 @@ +#include + +struct s { + signed char a: 6; + unsigned int b: 4; +}; + +int f(struct s * x) +{ + return (x->a)-- - ++(x->b); +} + +struct s * ding(struct s * x) +{ + printf ("Ding!\n"); + return x; +} + +int main() +{ + struct s x; + + x.a = 28; + x.b = 2; + + printf("x = {a = %d, b = %d }\n", x.a, x.b); + printf("(x.a += 10) = %d\n", (x.a += 10)); + printf("(x.b = 17) = %d\n", (x.b = 17)); + printf("x = {a = %d, b = %d }\n", x.a, x.b); + printf("f(&x) = %d\n", f(&x)); + printf("f(&x) = %d\n", f(&x)); + printf("f(&x) = %d\n", f(&x)); + printf("x = {a = %d, b = %d }\n", x.a, x.b); + ding(&x)->a = 10; + printf("x = {a = %d, b = %d }\n", x.a, x.b); + ding(&x)->a += 2; + printf("x = {a = %d, b = %d }\n", x.a, x.b); + return 0; +} -- cgit