aboutsummaryrefslogtreecommitdiffstats
path: root/test/regression/struct12.c
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/regression/struct12.c
parentab1ddcd0d579d7e5760c6cfa84adbd55212c47e7 (diff)
parentf869da75c970aec78975f7154c806f29e3012b7a (diff)
downloadcompcert-52c6be30048bf9b77b9dd6bc66f052ee5386f16e.tar.gz
compcert-52c6be30048bf9b77b9dd6bc66f052ee5386f16e.zip
Merge branch 'master' of https://github.com/AbsInt/CompCert
Diffstat (limited to 'test/regression/struct12.c')
-rw-r--r--test/regression/struct12.c39
1 files changed, 39 insertions, 0 deletions
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;
+}
+