summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/misaligned-expand-1.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.dg/misaligned-expand-1.c')
-rw-r--r--gcc/testsuite/gcc.dg/misaligned-expand-1.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/misaligned-expand-1.c b/gcc/testsuite/gcc.dg/misaligned-expand-1.c
new file mode 100644
index 0000000000..b799b6b87c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/misaligned-expand-1.c
@@ -0,0 +1,41 @@
+/* Test that expand can generate correct loads of misaligned data even on
+ strict alignment platforms. */
+
+/* { dg-do run } */
+/* { dg-options "-O0" } */
+
+extern void abort ();
+
+typedef unsigned int myint __attribute__((aligned(1)));
+
+unsigned int
+foo (myint *p)
+{
+ return *p;
+}
+
+#define cst (int) 0xdeadbeef
+#define NUM 8
+
+struct blah
+{
+ char c;
+ myint i[NUM];
+};
+
+struct blah g;
+
+int
+main (int argc, char **argv)
+{
+ int i, k;
+ for (k = 0; k < NUM; k++)
+ {
+ g.i[k] = cst;
+ i = foo (&g.i[k]);
+
+ if (i != cst)
+ abort ();
+ }
+ return 0;
+}