aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>2015-07-08 12:04:28 +0200
committerXavier Leroy <xavier.leroy@inria.fr>2015-07-08 12:04:28 +0200
commit52c6be30048bf9b77b9dd6bc66f052ee5386f16e (patch)
tree87ab50782e40116d4b23b6f61d90030d304993dd /test
parentab1ddcd0d579d7e5760c6cfa84adbd55212c47e7 (diff)
parentf869da75c970aec78975f7154c806f29e3012b7a (diff)
downloadcompcert-52c6be30048bf9b77b9dd6bc66f052ee5386f16e.tar.gz
compcert-52c6be30048bf9b77b9dd6bc66f052ee5386f16e.zip
Merge branch 'master' of https://github.com/AbsInt/CompCert
Diffstat (limited to 'test')
-rw-r--r--test/regression/Makefile2
-rw-r--r--test/regression/Results/bitfields96
-rw-r--r--test/regression/Results/struct120
-rw-r--r--test/regression/bitfields1.c4
-rw-r--r--test/regression/bitfields9.c14
-rw-r--r--test/regression/struct12.c39
6 files changed, 52 insertions, 13 deletions
diff --git a/test/regression/Makefile b/test/regression/Makefile
index da7d5755..e2d94aa9 100644
--- a/test/regression/Makefile
+++ b/test/regression/Makefile
@@ -15,7 +15,7 @@ LIBS=$(LIBMATH)
TESTS=int32 int64 floats floats-basics \
expr1 expr6 funptr2 initializers initializers2 initializers3 \
volatile1 volatile2 volatile3 \
- funct3 expr5 struct7 struct8 struct11 casts1 casts2 char1 \
+ funct3 expr5 struct7 struct8 struct11 struct12 casts1 casts2 char1 \
sizeof1 sizeof2 binops bool for1 switch switch2 compound \
decl1 interop1 bitfields9 ptrs3
diff --git a/test/regression/Results/bitfields9 b/test/regression/Results/bitfields9
index ca74f1f4..a1d0e9fd 100644
--- a/test/regression/Results/bitfields9
+++ b/test/regression/Results/bitfields9
@@ -1,10 +1,10 @@
glob_s = { a = -12, b = 1 }
-glob_t = { c = 123, d = 0, e = -45 }
+glob_t = { c = 123, d = 1, e = -45 }
loc_s = { a = 11, b = 2 }
loc_t = { c = 11, d = 1, e = 2 }
compound_s = { a = 2, b = 3 }
-compound_t = { c = 2, d = 0, e = -11 }
+compound_t = { c = 2, d = 1, e = -11 }
loc_s = { a = 7, b = 2 }
loc_t = { c = 7, d = 1, e = 50 }
compound_s = { a = -14, b = 3 }
-compound_t = { c = 50, d = 0, e = -7 }
+compound_t = { c = 50, d = 1, e = -7 }
diff --git a/test/regression/Results/struct12 b/test/regression/Results/struct12
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/regression/Results/struct12
diff --git a/test/regression/bitfields1.c b/test/regression/bitfields1.c
index c6022dd1..5f6dfdd1 100644
--- a/test/regression/bitfields1.c
+++ b/test/regression/bitfields1.c
@@ -7,7 +7,7 @@ struct s {
struct t {
unsigned int c: 16;
- unsigned int d: 1;
+ _Bool d: 1;
short e: 8;
};
@@ -29,7 +29,7 @@ int main()
y.c = 12345;
y.d = 0;
y.e = 89;
- res = f(&x, &y, 1);
+ res = f(&x, &y, 2);
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);
diff --git a/test/regression/bitfields9.c b/test/regression/bitfields9.c
index b33c4064..be87057b 100644
--- a/test/regression/bitfields9.c
+++ b/test/regression/bitfields9.c
@@ -9,7 +9,7 @@ struct s {
struct t {
unsigned int c: 16;
- unsigned int d: 1;
+ _Bool d: 1;
short e: 8;
};
@@ -25,25 +25,25 @@ void print_t(char * msg, struct t p)
/* Global initialization */
struct s glob_s = { -12, 1 };
-struct t glob_t = { 123, 0, -45 };
+struct t glob_t = { 123, 2, -45 };
/* Local initialization */
-void f(int x, int y)
+void f(int x, int y, int z)
{
struct s loc_s = { x, y };
- struct t loc_t = { x, 1, y };
+ struct t loc_t = { x, z, y };
print_s("loc_s", loc_s);
print_t("loc_t", loc_t);
print_s("compound_s", (struct s) { y, x });
- print_t("compound_t", (struct t) { y, 0, -x });
+ print_t("compound_t", (struct t) { y, ~z, -x });
}
int main()
{
print_s("glob_s", glob_s);
print_t("glob_t", glob_t);
- f(11, 2);
- f(7, 50);
+ f(11, 2, 3);
+ f(7, 50, 2);
return 0;
}
diff --git a/test/regression/struct12.c b/test/regression/struct12.c
new file mode 100644
index 00000000..39e62b28
--- /dev/null
+++ b/test/regression/struct12.c
@@ -0,0 +1,39 @@
+/* This is was originally a regression test for bug 43784 of gcc.
+ See ISO/IEC 9899:TC3 ยง6.8.6.4p4 and footnote 139. */
+
+#include <stdio.h>
+
+struct s {
+ unsigned char a[256];
+};
+union u {
+ struct { struct s b; int c; } d;
+ struct { int c; struct s b; } e;
+};
+
+static union u v;
+static struct s *p = &v.d.b;
+static struct s *q = &v.e.b;
+
+static struct s __attribute__((noinline)) rp(void)
+{
+ return *p;
+}
+
+static void qp(void)
+{
+ *q = rp();
+}
+
+int main()
+{
+ int i;
+ for (i = 0; i < 256; i++)
+ p->a[i] = i;
+ qp();
+ for (i = 0; i < 256; i++)
+ if (q->a[i] != i)
+ printf("ERROR at %d: %d\n", i, q->a[i]);
+ return 0;
+}
+