func-vararg-alternate.h: New file.
authorJanis Johnson <janis187@us.ibm.com>
Tue, 27 Mar 2007 23:38:05 +0000 (23:38 +0000)
committerJanis Johnson <janis@gcc.gnu.org>
Tue, 27 Mar 2007 23:38:05 +0000 (23:38 +0000)
* gcc.dg/dfp/func-vararg-alternate.h: New file.
* gcc.dg/dfp/func-vararg-alternate-d32.c: New test.
* gcc.dg/dfp/func-vararg-alternate-d64.c: New test.
* gcc.dg/dfp/func-vararg-alternate-d128.c: New test.

From-SVN: r123282

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/dfp/func-vararg-alternate-d128.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/dfp/func-vararg-alternate-d32.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/dfp/func-vararg-alternate-d64.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/dfp/func-vararg-alternate.h [new file with mode: 0644]

index 460abc78021682a7e9e880f19c3377c453183852..5457dfebfe835bce9e672cdfe815941919ffb99e 100644 (file)
@@ -1,5 +1,10 @@
 2007-03-27  Janis Johnson  <janis187@us.ibm.com>
 
+       * gcc.dg/dfp/func-vararg-alternate.h: New file.
+       * gcc.dg/dfp/func-vararg-alternate-d32.c: New test.
+       * gcc.dg/dfp/func-vararg-alternate-d64.c: New test.
+       * gcc.dg/dfp/func-vararg-alternate-d128.c: New test.
+
        * gcc.dg/dfp/func-vararg-mixed.c: Add optional debugging output.
        * gcc.dg/dfp/func-vararg-dfp.c: Ditto.
 
diff --git a/gcc/testsuite/gcc.dg/dfp/func-vararg-alternate-d128.c b/gcc/testsuite/gcc.dg/dfp/func-vararg-alternate-d128.c
new file mode 100644 (file)
index 0000000..e8fc027
--- /dev/null
@@ -0,0 +1,20 @@
+/* { dg-options "-std=gnu99" } */
+
+/* Simple test of vararg passing for problematic types with and without
+   double values passed between them.  */
+
+#define DTYPE _Decimal128
+#define ONE 1.0dl
+#define THREE 3.0dl
+#define SEVEN 7.0dl
+#define ELEVEN 11.0dl
+#define INTS 4
+
+#include "func-vararg-alternate.h"
+
+int
+main ()
+{
+  doit ();
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/dfp/func-vararg-alternate-d32.c b/gcc/testsuite/gcc.dg/dfp/func-vararg-alternate-d32.c
new file mode 100644 (file)
index 0000000..cd6853c
--- /dev/null
@@ -0,0 +1,20 @@
+/* { dg-options "-std=gnu99" } */
+
+/* Simple test of vararg passing for problematic types with and without
+   double values passed between them.  */
+
+#define DTYPE _Decimal32
+#define ONE 1.0df
+#define THREE 3.0df
+#define SEVEN 7.0df
+#define ELEVEN 11.0df
+#define INTS 1
+
+#include "func-vararg-alternate.h"
+
+int
+main ()
+{
+  doit ();
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/dfp/func-vararg-alternate-d64.c b/gcc/testsuite/gcc.dg/dfp/func-vararg-alternate-d64.c
new file mode 100644 (file)
index 0000000..3947001
--- /dev/null
@@ -0,0 +1,20 @@
+/* { dg-options "-std=gnu99" } */
+
+/* Simple test of vararg passing for problematic types with and without
+   double values passed between them.  */
+
+#define DTYPE _Decimal64
+#define ONE 1.0dd
+#define THREE 3.0dd
+#define SEVEN 7.0dd
+#define ELEVEN 11.0dd
+#define INTS 2
+
+#include "func-vararg-alternate.h"
+
+int
+main ()
+{
+  doit ();
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/dfp/func-vararg-alternate.h b/gcc/testsuite/gcc.dg/dfp/func-vararg-alternate.h
new file mode 100644 (file)
index 0000000..393111b
--- /dev/null
@@ -0,0 +1,150 @@
+/* Simple test of vararg passing for problematic types with and without
+   double values passed between them.  */
+
+#include <stdarg.h>
+#ifdef DBG
+#include <stdio.h>
+#endif
+
+extern void abort (void);
+
+int failcnt;
+DTYPE a[10];
+double b[10];
+
+union U {
+  DTYPE d;
+  unsigned int i[INTS];
+};
+
+void
+compare (double r, double s, int *p, int *q, int n, int line)
+{
+  int i;
+
+  for (i = 0; i < n; i++)
+    if (r != s || p[i] != q[i])
+#ifdef DBG
+      {
+       int j;
+
+       printf ("line %-3d", line);
+       for (j = 0; j < n; j++)
+         printf ("  %08x", p[j]);
+       printf ("    %10.2g\n        ", r);
+       for (j = 0; j < n; j++)
+         printf ("  %08x", q[j]);
+       printf ("    %10.2g\n\n", s);
+           
+       return;
+      }
+#else
+      abort ();
+#endif
+}
+
+void
+bar0 (int n, ...)
+{
+  union U u;
+  int j;
+  va_list ap;
+
+  va_start (ap, n);
+  for (j = 0; j < n; j++)
+    a[j] = va_arg (ap, DTYPE);
+  va_end (ap);
+}
+
+void
+bar1 (int n, ...)
+{
+  union U u;
+  int j;
+  va_list ap;
+
+  va_start (ap, n);
+  for (j = 0; j < n; j++)
+    {
+      a[j] = va_arg (ap, DTYPE);
+      b[j] = va_arg (ap, double);
+    }
+  va_end (ap);
+}
+
+void
+bar2 (int n, ...)
+{
+  union U u;
+  int j;
+  va_list ap;
+
+  va_start (ap, n);
+  for (j = 0; j < n; j++)
+    {
+      b[j] = va_arg (ap, double);
+      a[j] = va_arg (ap, DTYPE);
+    }
+  va_end (ap);
+}
+
+void
+doit ()
+{
+  DTYPE x, y, z;
+  union U u1, u2;
+
+  /* Sanity check that test setup is right, especially for long double
+     which can be changed by command line option.  */
+  if (INTS * 4 != sizeof (DTYPE))
+    {
+#ifdef DBG
+      printf ("test error: INTS = %d, sizeof (DTYPE) =  %d\n",
+             INTS, sizeof (DTYPE));
+#endif
+      abort ();
+    }
+
+  x = ONE / THREE;
+  y = ONE / SEVEN;
+  z = ONE / ELEVEN;
+
+  bar0 (1, x);
+  u1.d = x; u2.d = a[0]; compare (0.0, 0.0, u1.i, u2.i, INTS, __LINE__);
+
+  bar0 (2, x, y);
+  u1.d = x; u2.d = a[0]; compare (0.0, 0.0, u1.i, u2.i, INTS, __LINE__);
+  u1.d = y; u2.d = a[1]; compare (0.0, 0.0, u1.i, u2.i, INTS, __LINE__);
+
+  bar0 (3, x, y, z);
+  u1.d = x; u2.d = a[0]; compare (0.0, 0.0, u1.i, u2.i, INTS, __LINE__);
+  u1.d = y; u2.d = a[1]; compare (0.0, 0.0, u1.i, u2.i, INTS, __LINE__);
+  u1.d = z; u2.d = a[2]; compare (0.0, 0.0, u1.i, u2.i, INTS, __LINE__);
+
+  bar1 (1, x, 1.5);
+  u1.d = x; u2.d = a[0]; compare (1.5, b[0], u1.i, u2.i, INTS, __LINE__);
+
+  bar1 (2, x, 1.5, y, 2.5);
+  u1.d = x; u2.d = a[0]; compare (1.5, b[0], u1.i, u2.i, INTS, __LINE__);
+  u1.d = y; u2.d = a[1]; compare (2.5, b[1], u1.i, u2.i, INTS, __LINE__);
+
+  bar1 (3, x, 1.5, y, 2.5, z, 3.5);
+  u1.d = x; u2.d = a[0]; compare (1.5, b[0], u1.i, u2.i, INTS, __LINE__);
+  u1.d = y; u2.d = a[1]; compare (2.5, b[1], u1.i, u2.i, INTS, __LINE__);
+  u1.d = z; u2.d = a[2]; compare (3.5, b[2], u1.i, u2.i, INTS, __LINE__);
+
+  bar2 (1, 1.5, x);
+  u1.d = x; u2.d = a[0]; compare (1.5, b[0], u1.i, u2.i, INTS, __LINE__);
+
+  bar2 (2, 1.5, x, 2.5, y);
+  u1.d = x; u2.d = a[0]; compare (1.5, b[0], u1.i, u2.i, INTS, __LINE__);
+  u1.d = y; u2.d = a[1]; compare (2.5, b[1], u1.i, u2.i, INTS, __LINE__);
+
+  bar2 (3, 1.5, x, 2.5, y, 3.5, z);
+  u1.d = x; u2.d = a[0]; compare (1.5, b[0], u1.i, u2.i, INTS, __LINE__);
+  u1.d = y; u2.d = a[1]; compare (2.5, b[1], u1.i, u2.i, INTS, __LINE__);
+  u1.d = z; u2.d = a[2]; compare (3.5, b[2], u1.i, u2.i, INTS, __LINE__);
+
+  if (failcnt != 0)
+    abort ();
+}