PATCH: Add a testcase for PR target/15302

H. J. Lu hjl@lucon.org
Sun May 9 14:19:00 GMT 2004


Here is a testcase for PR target/15302.


H.J.
---
2004-05-07  H.J. Lu  <hongjiu.lu@intel.com>

	* gcc.dg/compat/struct-complex-1.h: New file.  Add a test for
	PR target/15302.
	* gcc.dg/compat/struct-complex-1_main.c: Likewise.
	* gcc.dg/compat/struct-complex-1_x.c: Likewise.
	* gcc.dg/compat/struct-complex-1_y.c: Likewise.

--- gcc/testsuite/gcc.dg/compat/struct-complex-1.h.complex	2004-05-08 15:09:50.000000000 -0700
+++ gcc/testsuite/gcc.dg/compat/struct-complex-1.h	2004-05-08 15:04:50.000000000 -0700
@@ -0,0 +1,17 @@
+#include <complex.h>
+
+struct st
+{
+  int s1;
+  float complex x;
+  int s2;
+};
+
+typedef struct { float r, i; } _complex;
+
+struct stc
+{
+  int s1;
+  _complex x;
+  int s2;
+};
--- gcc/testsuite/gcc.dg/compat/struct-complex-1_main.c.complex	2004-05-08 15:09:50.000000000 -0700
+++ gcc/testsuite/gcc.dg/compat/struct-complex-1_main.c	2004-05-08 15:03:11.000000000 -0700
@@ -0,0 +1,21 @@
+/* { dg-options "-O" } */
+
+#ifdef __x86_64__
+/* Test function argument passing.  PR target/15302.  */
+
+extern void struct_complex_1_x (void);
+extern void exit (int);
+
+int
+main ()
+{
+  struct_complex_1_x ();
+  exit (0);
+}
+#else
+int
+main ()
+{
+  return 0;
+}
+#endif
--- gcc/testsuite/gcc.dg/compat/struct-complex-1_x.c.complex	2004-05-08 15:09:50.000000000 -0700
+++ gcc/testsuite/gcc.dg/compat/struct-complex-1_x.c	2004-05-08 15:08:30.000000000 -0700
@@ -0,0 +1,29 @@
+/* { dg-options "-O" } */
+
+#ifdef __x86_64__
+#include "struct-complex-1.h"
+
+struct st st1;
+struct stc st2;
+
+extern void foo ();
+extern void bar ();
+
+int
+struct_complex_1_x ()
+{
+  st1.s1 = 1;
+  st1.s2 = 2;
+  __real__ st1.x = 2;
+  __imag__ st1.x = 4;
+  st2.s1 = 1;
+  st2.s2 = 2;
+  st2.x.r = 2;
+  st2.x.i = 4;
+  foo (st1);
+  foo (st2);
+  bar (st1);
+  bar (st2);
+  return 0;
+}
+#endif
--- gcc/testsuite/gcc.dg/compat/struct-complex-1_y.c.complex	2004-05-08 15:09:50.000000000 -0700
+++ gcc/testsuite/gcc.dg/compat/struct-complex-1_y.c	2004-05-08 15:09:33.000000000 -0700
@@ -0,0 +1,21 @@
+/* { dg-options "-O" } */
+
+#ifdef __x86_64__
+#include <stdlib.h>
+#include "struct-complex-1.h"
+
+void
+bar(struct st x)
+{
+  if (x.s1 != 1 || x.s2 != 2
+      || __real__ x.x != 2 || __imag__ x.x != 4)
+    abort ();
+}
+
+void
+foo(struct stc x)
+{
+  if (x.s1 != 1 || x.s2 != 2 || x.x.r != 2 || x.x.i != 4)
+    abort ();
+}
+#endif



More information about the Gcc-patches mailing list