| 1 |
/* { dg-skip-if "requires io" { freestanding } } */ |
| 2 |
|
| 3 |
/* This test tests complex conjugate and passing/returning of |
| 4 |
complex parameter. */ |
| 5 |
|
| 6 |
#include <stdlib.h> |
| 7 |
#include <stdio.h> |
| 8 |
|
| 9 |
int e; |
| 10 |
|
| 11 |
#define TEST(TYPE, FUNC) \ |
| 12 |
__complex__ TYPE \ |
| 13 |
ctest_ ## FUNC (__complex__ TYPE x) \ |
| 14 |
{ \ |
| 15 |
__complex__ TYPE res; \ |
| 16 |
\ |
| 17 |
res = ~x; \ |
| 18 |
\ |
| 19 |
return res; \ |
| 20 |
} \ |
| 21 |
\ |
| 22 |
void \ |
| 23 |
test_ ## FUNC (void) \ |
| 24 |
{ \ |
| 25 |
__complex__ TYPE res, x; \ |
| 26 |
\ |
| 27 |
x = 1.0 + 2.0i; \ |
| 28 |
\ |
| 29 |
res = ctest_ ## FUNC (x); \ |
| 30 |
\ |
| 31 |
if (res != 1.0 - 2.0i) \ |
| 32 |
{ \ |
| 33 |
printf ("test_" #FUNC " failed\n"); \ |
| 34 |
++e; \ |
| 35 |
} \ |
| 36 |
} |
| 37 |
|
| 38 |
|
| 39 |
TEST(float, float) |
| 40 |
TEST(double, double) |
| 41 |
TEST(long double, long_double) |
| 42 |
TEST(int, int) |
| 43 |
TEST(long int, long_int) |
| 44 |
|
| 45 |
int |
| 46 |
main (void) |
| 47 |
{ |
| 48 |
|
| 49 |
e = 0; |
| 50 |
|
| 51 |
test_float (); |
| 52 |
test_double (); |
| 53 |
test_long_double (); |
| 54 |
test_int (); |
| 55 |
test_long_int (); |
| 56 |
|
| 57 |
if (e != 0) |
| 58 |
abort (); |
| 59 |
|
| 60 |
return 0; |
| 61 |
} |