From df049e595fcfd94fda08283ae57bbeaa36947854 Mon Sep 17 00:00:00 2001 From: "Kaveh R. Ghazi" Date: Tue, 9 Sep 2003 03:13:45 +0000 Subject: builtins-1.c: Test existing _Complex functions. * gcc.dg/builtins-1.c: Test existing _Complex functions. * gcc.dg/torture/builtin-attr-1.c: Likewise. From-SVN: r71225 --- gcc/testsuite/ChangeLog | 5 +++ gcc/testsuite/gcc.dg/builtins-1.c | 25 +++++++++++ gcc/testsuite/gcc.dg/torture/builtin-attr-1.c | 60 +++++++++++++++++++++++++++ 3 files changed, 90 insertions(+) (limited to 'gcc') diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3d9d367..b50ad3d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2003-09-08 Kaveh R. Ghazi + + * gcc.dg/builtins-1.c: Test existing _Complex functions. + * gcc.dg/torture/builtin-attr-1.c: Likewise. + 2003-09-08 Mark Mitchell PR c++/11786 diff --git a/gcc/testsuite/gcc.dg/builtins-1.c b/gcc/testsuite/gcc.dg/builtins-1.c index 85636fa..adb27c2 100644 --- a/gcc/testsuite/gcc.dg/builtins-1.c +++ b/gcc/testsuite/gcc.dg/builtins-1.c @@ -84,6 +84,25 @@ double test_##FN(double x, double *y, double *z) { __builtin_##FN(x, y, z); retu 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 --git a/gcc/testsuite/gcc.dg/torture/builtin-attr-1.c b/gcc/testsuite/gcc.dg/torture/builtin-attr-1.c index 2bb16c3..451081d 100644 --- a/gcc/testsuite/gcc.dg/torture/builtin-attr-1.c +++ b/gcc/testsuite/gcc.dg/torture/builtin-attr-1.c @@ -124,6 +124,32 @@ void test_builtin_##FN##f(float f1, float f2, float f3) \ 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, float f3) \ 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) See http://gcc.gnu.org/ml/gcc-patches/2003-09/msg00040.html */ +CPTEST1 (cimag) +CPTEST1 (conj) +CPTEST1 (creal) + /* Various other const builtins. */ TEST1 (abs, int) BUILTIN_TEST1 (clz, int) -- cgit v1.1