Patch: add tests for _Complex builtins

Kaveh R. Ghazi ghazi@caip.rutgers.edu
Wed Sep 3 15:13:00 GMT 2003


This patch adds tests for the existing _Complex builtin functions.  It
relies on a fix by Roger posted here for the cabs tests to pass:
http://gcc.gnu.org/ml/gcc-patches/2003-09/msg00040.html

Tested in conjunction with the above patch on sparc-sun-solaris2.7 via
a C-only "make check".

I'll install this as "obvious" once Roger's patch goes in.

		--Kaveh


2003-08-31  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* gcc.dg/builtins-1.c: Test existing _Complex functions.
	* gcc.dg/torture/builtin-attr-1.c: Likewise.

diff -rup orig/egcc-CVS20030830/gcc/testsuite/gcc.dg/builtins-1.c egcc-CVS20030830/gcc/testsuite/gcc.dg/builtins-1.c
--- orig/egcc-CVS20030830/gcc/testsuite/gcc.dg/builtins-1.c	2003-08-28 17:56:46.000000000 -0400
+++ egcc-CVS20030830/gcc/testsuite/gcc.dg/builtins-1.c	2003-08-30 11:17:27.729288844 -0400
@@ -84,6 +84,25 @@ double test_##FN(double x, double *y, do
 float test_##FN##f(float x, float *y, float *z) { __builtin_##FN##f(x, y, z); return *y * *z; } \
 long double test_##FN##l(long double x, long double *y, long double *z) { __builtin_##FN##l(x, y, z); return *y * *z; } 
 
+/* Test Complex functions taking one Complex argument.  */
+#define CPTEST1(FN) \
+_Complex double test_##FN(_Complex double x) { return __builtin_##FN(x); } \
+_Complex float test_##FN##f(_Complex float x) { return __builtin_##FN##f(x); } \
+_Complex long double test_##FN##l(_Complex long double x) { return __builtin_##FN##l(x); } 
+
+/* Test Complex functions taking one Complex argument and returning an FP type.  */
+#define CPTEST1RETFP(FN) \
+double test_##FN(_Complex double x) { return __builtin_##FN(x); } \
+float test_##FN##f(_Complex float x) { return __builtin_##FN##f(x); } \
+long double test_##FN##l(_Complex long double x) { return __builtin_##FN##l(x); } 
+
+/* Test Complex functions taking two Complex arguments.  */
+#define CPTEST2(FN) \
+_Complex double test_##FN(_Complex double x, _Complex double y) { return __builtin_##FN(x,y); } \
+_Complex float test_##FN##f(_Complex float x, _Complex float y) { return __builtin_##FN##f(x,y); } \
+_Complex long double test_##FN##l(_Complex long double x, _Complex long double y) { return __builtin_##FN##l(x,y); } 
+
+
 /* Keep this list sorted alphabetically by function name.  */
 FPTEST1     (acos)
 FPTEST1     (acosh)
@@ -158,3 +177,9 @@ FPTEST1     (trunc)
 FPTEST1     (y0)
 FPTEST1     (y1)
 FPTEST2ARG1 (yn, int)
+
+/* Keep this list sorted alphabetically by function name.  */
+CPTEST1RETFP (cabs)
+CPTEST1RETFP (cimag)
+CPTEST1      (conj)
+CPTEST1RETFP (creal)
diff -rup orig/egcc-CVS20030830/gcc/testsuite/gcc.dg/torture/builtin-attr-1.c egcc-CVS20030830/gcc/testsuite/gcc.dg/torture/builtin-attr-1.c
--- orig/egcc-CVS20030830/gcc/testsuite/gcc.dg/torture/builtin-attr-1.c	2003-08-28 17:20:59.000000000 -0400
+++ egcc-CVS20030830/gcc/testsuite/gcc.dg/torture/builtin-attr-1.c	2003-08-30 11:18:54.860975490 -0400
@@ -124,6 +124,32 @@ void test_builtin_##FN##f(float f1, floa
 void test_builtin_##FN##l(long double ld1, long double ld2, long double ld3) \
 { if (__builtin_##FN##l(ld1,ld2,ld3) != __builtin_##FN##l(ld1,ld2,ld3)) link_failure_builtin_##FN##l(); }
 
+/* Test the __builtin_ functions taking one complex argument (with the
+   "f" and "l" variants).  */
+#define BUILTIN_CPTEST1(FN) \
+extern void link_failure_builtin_##FN(void); \
+extern void link_failure_builtin_##FN##f(void); \
+extern void link_failure_builtin_##FN##l(void); \
+void test_builtin_##FN(_Complex double d) \
+{ if (__builtin_##FN(d) != __builtin_##FN(d)) link_failure_builtin_##FN(); } \
+void test_builtin_##FN##f(_Complex float f) \
+{ if (__builtin_##FN##f(f) != __builtin_##FN##f(f)) link_failure_builtin_##FN##f(); } \
+void test_builtin_##FN##l(_Complex long double ld) \
+{ if (__builtin_##FN##l(ld) != __builtin_##FN##l(ld)) link_failure_builtin_##FN##l(); }
+
+/* Test the __builtin_ functions taking two complex arguments (with
+   the "f" and "l" variants).  */
+#define BUILTIN_CPTEST2(FN) \
+extern void link_failure_builtin_##FN(void); \
+extern void link_failure_builtin_##FN##f(void); \
+extern void link_failure_builtin_##FN##l(void); \
+void test_builtin_##FN(_Complex double d1, _Complex double d2) \
+{ if (__builtin_##FN(d1,d2) != __builtin_##FN(d1,d2)) link_failure_builtin_##FN(); } \
+void test_builtin_##FN##f(_Complex float f1, _Complex float f2) \
+{ if (__builtin_##FN##f(f1,f2) != __builtin_##FN##f(f1,f2)) link_failure_builtin_##FN##f(); } \
+void test_builtin_##FN##l(_Complex long double ld1, _Complex long double ld2) \
+{ if (__builtin_##FN##l(ld1,ld2) != __builtin_##FN##l(ld1,ld2)) link_failure_builtin_##FN##l(); }
+
 /* These macros additionally test the non-__builtin_ functions.  */
 
 /* Test the functions taking one FP argument (with the "f" and "l"
@@ -198,6 +224,34 @@ void test_##FN##f(float f1, float f2, fl
 void test_##FN##l(long double ld1, long double ld2, long double ld3) \
 { if (FN##l(ld1,ld2,ld3) != FN##l(ld1,ld2,ld3)) link_failure_##FN##l(); }
 
+/* Test the functions taking one complex argument (with the "f" and
+   "l" variants).  */
+#define CPTEST1(FN) \
+BUILTIN_CPTEST1(FN) \
+extern void link_failure_##FN(void); \
+extern void link_failure_##FN##f(void); \
+extern void link_failure_##FN##l(void); \
+void test_##FN(_Complex double d) \
+{ if (FN(d) != FN(d)) link_failure_##FN(); } \
+void test_##FN##f(_Complex float f) \
+{ if (FN##f(f) != FN##f(f)) link_failure_##FN##f(); } \
+void test_##FN##l(_Complex long double ld) \
+{ if (FN##l(ld) != FN##l(ld)) link_failure_##FN##l(); }
+
+/* Test the functions taking two complex arguments (with the "f" and
+   "l" variants).  */
+#define CPTEST2(FN) \
+BUILTIN_CPTEST2(FN) \
+extern void link_failure_##FN(void); \
+extern void link_failure_##FN##f(void); \
+extern void link_failure_##FN##l(void); \
+void test_##FN(_Complex double d1, _Complex double d2) \
+{ if (FN(d1,d2) != FN(d1,d2)) link_failure_##FN(); } \
+void test_##FN##f(_Complex float f1, _Complex float f2) \
+{ if (FN##f(f1,f2) != FN##f(f1,f2)) link_failure_##FN##f(); } \
+void test_##FN##l(_Complex long double ld1, _Complex long double ld2) \
+{ if (FN##l(ld1,ld2) != FN##l(ld1,ld2)) link_failure_##FN##l(); }
+
 
 /* Test the math builtins.  */
 FPTEST1            (acos)
@@ -270,6 +324,12 @@ FPTEST1            (y0)
 FPTEST1            (y1)
 FPTEST2ARG1        (yn, int)
 
+/* Test the complex math builtins.  */
+CPTEST1 (cabs)
+CPTEST1 (cimag)
+CPTEST1 (conj)
+CPTEST1 (creal)
+
 /* Various other const builtins.  */
 TEST1         (abs, int)
 BUILTIN_TEST1 (clz, int)



More information about the Gcc-patches mailing list