summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/misaligned-expand-3.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.dg/misaligned-expand-3.c')
-rw-r--r--gcc/testsuite/gcc.dg/misaligned-expand-3.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/misaligned-expand-3.c b/gcc/testsuite/gcc.dg/misaligned-expand-3.c
new file mode 100644
index 0000000000..5b1c7e7e07
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/misaligned-expand-3.c
@@ -0,0 +1,43 @@
+/* Test that expand can generate correct stores to misaligned data of complex
+ type even on strict alignment platforms. */
+
+/* { dg-do run } */
+/* { dg-options "-O0" } */
+
+extern void abort ();
+
+typedef _Complex float mycmplx __attribute__((aligned(1)));
+
+void
+foo (mycmplx *p, float r, float i)
+{
+ __real__ *p = r;
+ __imag__ *p = i;
+}
+
+#define cvr 3.2f
+#define cvi 2.5f
+#define NUM 8
+
+struct blah
+{
+ char c;
+ mycmplx x[NUM];
+} __attribute__((packed));
+
+struct blah g;
+
+int
+main (int argc, char **argv)
+{
+ int k;
+
+ for (k = 0; k < NUM; k++)
+ {
+ foo (&g.x[k], cvr, cvi);
+ if (__real__ g.x[k] != cvr
+ || __imag__ g.x[k] != cvi)
+ abort ();
+ }
+ return 0;
+}