1 /* Test __builtin_complex semantics. */
3 /* { dg-options "-std=c11 -pedantic-errors" } */
4 /* { dg-add-options ieee } */
6 extern void exit (int);
7 extern void abort (void);
9 #define COMPARE_BODY(A, B, TYPE, COPYSIGN) \
11 TYPE s1 = COPYSIGN ((TYPE) 1.0, A); \
12 TYPE s2 = COPYSIGN ((TYPE) 1.0, B); \
15 if ((__builtin_isnan (A) != 0) != (__builtin_isnan (B) != 0)) \
17 if ((A != B) != (__builtin_isnan (A) != 0)) \
23 comparef (float a
, float b
)
25 COMPARE_BODY (a
, b
, float, __builtin_copysignf
);
30 compare (double a
, double b
)
32 COMPARE_BODY (a
, b
, double, __builtin_copysign
);
36 comparel (long double a
, long double b
)
38 COMPARE_BODY (a
, b
, long double, __builtin_copysignl
);
43 comparecf (_Complex
float a
, float r
, float i
)
45 comparef (__real__ a
, r
);
46 comparef (__imag__ a
, i
);
51 comparec (_Complex
double a
, double r
, double i
)
53 compare (__real__ a
, r
);
54 compare (__imag__ a
, i
);
58 comparecl (_Complex
long double a
, long double r
, long double i
)
60 comparel (__real__ a
, r
);
61 comparel (__imag__ a
, i
);
64 #define VERIFY(A, B, TYPE, COMPARE) \
68 _Complex TYPE cr = __builtin_complex (a, b); \
69 static _Complex TYPE cs = __builtin_complex (A, B); \
74 #define ALL_CHECKS(PZ, NZ, NAN, INF, TYPE, COMPARE) \
76 VERIFY (PZ, PZ, TYPE, COMPARE); \
77 VERIFY (PZ, NZ, TYPE, COMPARE); \
78 VERIFY (PZ, NAN, TYPE, COMPARE); \
79 VERIFY (PZ, INF, TYPE, COMPARE); \
80 VERIFY (NZ, PZ, TYPE, COMPARE); \
81 VERIFY (NZ, NZ, TYPE, COMPARE); \
82 VERIFY (NZ, NAN, TYPE, COMPARE); \
83 VERIFY (NZ, INF, TYPE, COMPARE); \
84 VERIFY (NAN, PZ, TYPE, COMPARE); \
85 VERIFY (NAN, NZ, TYPE, COMPARE); \
86 VERIFY (NAN, NAN, TYPE, COMPARE); \
87 VERIFY (NAN, INF, TYPE, COMPARE); \
88 VERIFY (INF, PZ, TYPE, COMPARE); \
89 VERIFY (INF, NZ, TYPE, COMPARE); \
90 VERIFY (INF, NAN, TYPE, COMPARE); \
91 VERIFY (INF, INF, TYPE, COMPARE); \
98 ALL_CHECKS (0.0f
, -0.0f
, __builtin_nanf(""), __builtin_inff(),
106 ALL_CHECKS (0.0, -0.0, __builtin_nan(""), __builtin_inf(),
111 check_long_double (void)
113 ALL_CHECKS (0.0l, -0.0l, __builtin_nanl(""), __builtin_infl(),
114 long double, comparecl
);
122 check_long_double ();