diff options
author | xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e> | 2010-08-18 09:06:55 +0000 |
---|---|---|
committer | xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e> | 2010-08-18 09:06:55 +0000 |
commit | a15858a0a8fcea82db02fe8c9bd2ed912210419f (patch) | |
tree | 5c0c19439f0d0f9e8873ce0dad2034cb9cafc4ba /test/regression | |
parent | adedca3a1ff17ff8ac66eb2bcd533a50df0927a0 (diff) | |
download | compcert-a15858a0a8fcea82db02fe8c9bd2ed912210419f.tar.gz compcert-a15858a0a8fcea82db02fe8c9bd2ed912210419f.zip |
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
Diffstat (limited to 'test/regression')
-rw-r--r-- | test/regression/Makefile | 5 | ||||
-rw-r--r-- | test/regression/Results/bitfields4 | 12 | ||||
-rw-r--r-- | test/regression/Results/struct7 | 3 | ||||
-rw-r--r-- | test/regression/Results/struct8 | 3 | ||||
-rw-r--r-- | test/regression/bitfields4.c | 39 | ||||
-rw-r--r-- | test/regression/struct7.c | 20 | ||||
-rw-r--r-- | test/regression/struct8.c | 8 |
7 files changed, 85 insertions, 5 deletions
diff --git a/test/regression/Makefile b/test/regression/Makefile index 4ebf042d..06ad9efe 100644 --- a/test/regression/Makefile +++ b/test/regression/Makefile @@ -1,13 +1,14 @@ include ../../Makefile.config CCOMP=../../ccomp -CCOMPFLAGS=-stdlib ../../runtime -dparse -dclight -dasm \ +CCOMPFLAGS=-stdlib ../../runtime -dparse -dcmedium -dclight -dasm \ -fstruct-passing -fstruct-assign -fbitfields LIBS=$(LIBMATH) # Can run and have reference output in Results -TESTS=bitfields1 bitfields2 bitfields3 expr1 initializers volatile2 \ +TESTS=bitfields1 bitfields2 bitfields3 bitfields4 \ + expr1 initializers volatile2 \ funct3 expr5 struct7 struct8 casts1 casts2 # Other tests: should compile to .s without errors (but expect warnings) diff --git a/test/regression/Results/bitfields4 b/test/regression/Results/bitfields4 new file mode 100644 index 00000000..ff8e093a --- /dev/null +++ b/test/regression/Results/bitfields4 @@ -0,0 +1,12 @@ +x = {a = 28, b = 2 } +(x.a += 10) = -26 +(x.b = 17) = 1 +x = {a = -26, b = 1 } +f(&x) = -28 +f(&x) = -30 +f(&x) = -32 +x = {a = -29, b = 4 } +Ding! +x = {a = 10, b = 4 } +Ding! +x = {a = 12, b = 4 } diff --git a/test/regression/Results/struct7 b/test/regression/Results/struct7 index ae630bf1..597007c4 100644 --- a/test/regression/Results/struct7 +++ b/test/regression/Results/struct7 @@ -1,4 +1,7 @@ A2 = { 1234, 3.141590, { 'H', ... , 'o' } } +A2 = { 1234, 3.141590, { 'H', ... , 'o' } } +B2 = { 1, ..., 5, ..., 0 } B2 = { 1, ..., 5, ..., 0 } C2.c = 'z' D2.v = { 0, ..., 4, ..., 0 } +AA[0] = { 1234, 3.141590, { 'H', ... , 'o' } } diff --git a/test/regression/Results/struct8 b/test/regression/Results/struct8 index a2151938..19ec15d2 100644 --- a/test/regression/Results/struct8 +++ b/test/regression/Results/struct8 @@ -1,2 +1,5 @@ a = { 123, 2.718000, 'a' } b = { 125, 5.436000, 'f' } +c = { 128, 16.308000, 'f' } +d = { 125, 5.436000, 'f' } +e = { 128, 16.308000, 'f' } 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 <stdio.h> + +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; +} diff --git a/test/regression/struct7.c b/test/regression/struct7.c index 136602bf..fe3ef827 100644 --- a/test/regression/struct7.c +++ b/test/regression/struct7.c @@ -29,8 +29,8 @@ union u2 D; int main() { - struct small A2; - struct big B2; + struct small A1, A2, AA[1]; + struct big B1, B2; union u1 C2; union u2 D2; int i; @@ -42,10 +42,18 @@ int main() printf("A2 = { %d, %f, { '%c', ... , '%c' } }\n", A2.x, A2.d, A2.c[0], A2.c[4]); + A2 = (A1 = A); + printf("A2 = { %d, %f, { '%c', ... , '%c' } }\n", + A2.x, A2.d, A2.c[0], A2.c[4]); + B2 = B; printf("B2 = { %d, ..., %d, ..., %d }\n", B2.x[0], B2.x[4], B2.x[99]); + B2 = (B1 = B); + printf("B2 = { %d, ..., %d, ..., %d }\n", + B2.x[0], B2.x[4], B2.x[99]); + C2 = C; printf("C2.c = '%c'\n", C2.c); @@ -53,6 +61,14 @@ int main() printf("D2.v = { %d, ..., %d, ..., %d }\n", D2.v.x[0], D2.v.x[4], D2.v.x[99]); + AA[0] = A; + A1.x = 0; + A2.x = 0; + AA[A1.x] = AA[A2.x]; + + printf("AA[0] = { %d, %f, { '%c', ... , '%c' } }\n", + AA[0].x, AA[0].d, AA[0].c[0], AA[0].c[4]); + return 0; } diff --git a/test/regression/struct8.c b/test/regression/struct8.c index 989c3524..a100cbe3 100644 --- a/test/regression/struct8.c +++ b/test/regression/struct8.c @@ -16,8 +16,14 @@ struct S f(struct S s, int scale) int main() { struct S a = { 123, 2.718, 'a' }; - struct S b = f(a, 2); + struct S b, c, d, e; + b = f(a, 2); + c = f(f(a, 2), 3); + e = f((d = f(a, 2)), 3); printf("a = { %d, %f, '%c' }\n", a.x, a.d, a.c); printf("b = { %d, %f, '%c' }\n", b.x, b.d, b.c); + printf("c = { %d, %f, '%c' }\n", c.x, c.d, c.c); + printf("d = { %d, %f, '%c' }\n", d.x, d.d, d.c); + printf("e = { %d, %f, '%c' }\n", e.x, e.d, e.c); return 0; } |