summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2010-08-18 09:06:55 +0000
committerGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2010-08-18 09:06:55 +0000
commita15858a0a8fcea82db02fe8c9bd2ed912210419f (patch)
tree5c0c19439f0d0f9e8873ce0dad2034cb9cafc4ba /test
parentadedca3a1ff17ff8ac66eb2bcd533a50df0927a0 (diff)
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')
-rw-r--r--test/c/Makefile4
-rw-r--r--test/regression/Makefile5
-rw-r--r--test/regression/Results/bitfields412
-rw-r--r--test/regression/Results/struct73
-rw-r--r--test/regression/Results/struct83
-rw-r--r--test/regression/bitfields4.c39
-rw-r--r--test/regression/struct7.c20
-rw-r--r--test/regression/struct8.c8
8 files changed, 87 insertions, 7 deletions
diff --git a/test/c/Makefile b/test/c/Makefile
index 3f2df78..b4fd1fd 100644
--- a/test/c/Makefile
+++ b/test/c/Makefile
@@ -1,7 +1,7 @@
include ../../Makefile.config
CCOMP=../../ccomp
-CCOMPFLAGS=-stdlib ../../runtime -fmadd -dclight -dasm
+CCOMPFLAGS=-stdlib ../../runtime -fmadd -dcmedium -dclight -dasm
CFLAGS=-O1 -Wall
@@ -58,4 +58,4 @@ time_compcert:
clean:
rm -f *.compcert *.gcc
- rm -f *.light.c *.s *.o *~
+ rm -f *.light.c *.medium.c *.s *.o *~
diff --git a/test/regression/Makefile b/test/regression/Makefile
index 4ebf042..06ad9ef 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 0000000..ff8e093
--- /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 ae630bf..597007c 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 a215193..19ec15d 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 0000000..6333e6d
--- /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 136602b..fe3ef82 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 989c352..a100cbe 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;
}