summaryrefslogtreecommitdiff
path: root/test/regression
diff options
context:
space:
mode:
authorGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2010-02-17 13:44:32 +0000
committerGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2010-02-17 13:44:32 +0000
commit6224148fdd809170d138216d72b8e6180d626aec (patch)
treef67127b4ab6026f5e29d0b6aa69bec4f8a223fb2 /test/regression
parentf9ebf19ba3ca4c3ee67cc88bbea407d4dd734249 (diff)
Reorganization test directory
git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@1253 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
Diffstat (limited to 'test/regression')
-rw-r--r--test/regression/Results/initializersbin0 -> 306 bytes
-rw-r--r--test/regression/initializers.c68
-rw-r--r--test/regression/pragmas.c48
3 files changed, 116 insertions, 0 deletions
diff --git a/test/regression/Results/initializers b/test/regression/Results/initializers
new file mode 100644
index 0000000..979eff3
--- /dev/null
+++ b/test/regression/Results/initializers
Binary files differ
diff --git a/test/regression/initializers.c b/test/regression/initializers.c
new file mode 100644
index 0000000..97ce99b
--- /dev/null
+++ b/test/regression/initializers.c
@@ -0,0 +1,68 @@
+#include <stdio.h>
+
+char x1 = 'x';
+
+int x2 = 12345;
+
+double x3 = 3.14159;
+
+char x4[4] = { 'a', 'b', 'c', 'd' };
+
+int x5[10] = { 1, 2, 3 };
+
+struct { int y; int z; } x6 = { 4, 5 };
+
+struct { int y; char z; } x7 = { 6, 'u' };
+
+struct { char y; int z; } x8 = { 'v', 7 };
+
+struct { char y[9]; double z; } x9 = { { 'a', 'b' }, 2.718 };
+
+struct {
+ struct { char y; int z; } u;
+ double v;
+} x10 = { { 'v', 7 }, 2.718 };
+
+float x11 = 1 + 1 / 3.14159;
+
+double x12 = 1 / 3.14159 + 1;
+
+typedef enum { AAA , BBB } MyEnum;
+
+const MyEnum x13[2] = { AAA, BBB };
+
+int * x14 = &x2;
+
+struct { char * y; int * z; float * u; double * v; } x15 = { x4, x5, &x11, &x12 };
+
+int main(int argc, char ** argv)
+{
+ int i;
+
+ printf("x1 = '%c'\n", x1);
+ printf("x2 = %d\n", x2);
+ printf("x3 = %.5f\n", x3);
+ printf("x4 = { '%c', '%c', '%c', '%c' }\n",
+ x4[0], x4[1], x4[2], x4[3]);
+ printf("x5 = { ");
+ for (i = 0; i < 10; i++) printf("%d, ", x5[i]);
+ printf("}\n");
+ printf("x6 = { %d, %d }\n", x6.y, x6.z);
+ printf("x7 = { %d, '%c' }\n", x7.y, x7.z);
+ printf("x8 = { '%c', %d }\n", x8.y, x8.z);
+ printf("x9 = { { ");
+ for (i = 0; i < 9; i++) printf("'%c', ", x9.y[i]);
+ printf("}, %.3f }\n", x9.z);
+ printf("x10 = { { '%c', %d }, %.3f }\n",
+ x10.u.y, x10.u.z, x10.v);
+ printf("x11 = %.10f\n", x11);
+ printf("x12 = %.10f\n", x12);
+ printf("x13 = { %d, %d }\n", x13[0], x13[1]);
+ if (x14 == &x2) printf("x14 ok\n"); else printf("x14 error\n");
+ if (x15.y == x4 && x15.z == x5 && x15.u == &x11 && x15.v == &x12)
+ printf("x15 ok\n");
+ else
+ printf("x15 error\n");
+ return 0;
+}
+
diff --git a/test/regression/pragmas.c b/test/regression/pragmas.c
new file mode 100644
index 0000000..43daa32
--- /dev/null
+++ b/test/regression/pragmas.c
@@ -0,0 +1,48 @@
+/* Default sections */
+
+int a; /* small data */
+const double b = 2.718; /* ro small data */
+int c[4]; /* large data */
+const char d[12]; /* ro large data */
+
+double g(void) { return a + b; }
+
+/* Custom sections */
+
+#pragma section MYCODE ".mycode" ".mycode" standard RX
+#pragma section MYDATA ".mydata_i" ".mydata_u" far-absolute RW
+#pragma section MYCONST ".myconst" ".myconst" far-absolute R
+#pragma section MYSDA ".mysda_i" ".mysda_u" near-data RW
+
+#pragma use_section MYDATA x, y
+int x;
+double y = 3.14;
+
+#pragma use_section MYCONST z
+char z[4] = { 'a', 'b', 'c', 'd' };
+
+#pragma use_section MYSDA u
+int u;
+
+#pragma use_section MYCODE f
+int f(int n)
+{
+ x += n;
+ u -= n;
+ return z[n];
+}
+
+/* Redefining some standard sections */
+
+#pragma section SCONST ".myconst" ".myconst" far-absolute R
+#pragma section DATA ".mysda_i" ".mysda_u" near-data RW
+#pragma section CODE ".mycode" ".mycode" standard RX
+
+const double v = 1.414;
+int w[10];
+
+double h(int n)
+{
+ w[n] ++;
+ return v;
+}