dg-torture.exp: Run c-c++-common torture tests.
[official-gcc.git] / gcc / testsuite / c-c++-common / torture / complex-sign-mul-one.c
blob014d813e99ed758a18ef71bc6ce01827dbd39c9d
1 /* Test complex arithmetic with signed zeros. Pure complex
2 multiplication with 1.0 + 0.0i. */
3 /* { dg-do run } */
4 /* { dg-options "-std=gnu99" { target c } } */
6 #include "complex-sign.h"
8 #define CHECK_MUL_INT(TYPE, COPY, ZERO, ZEROI, ONE, S1, S2, SR, SI) \
9 do { \
10 _Complex TYPE a1, b1, c1; \
11 volatile _Complex TYPE a2, b2, c2; \
12 a1 = ENCODE(ZERO, ZEROI, S1, S2); \
13 CHECK_RES (a1, COPY, S1, S2); \
14 b1 = ONE + ZEROI; \
15 c1 = a1 * b1; \
16 CHECK_RES (c1, COPY, SR, SI); \
17 c1 = a1 * (ONE + ZEROI); \
18 CHECK_RES (c1, COPY, SR, SI); \
19 a2 = ENCODE(ZERO, ZEROI, S1, S2); \
20 CHECK_RES (a2, COPY, S1, S2); \
21 b2 = ONE + ZEROI; \
22 c2 = a2 * b2; \
23 CHECK_RES (c2, COPY, SR, SI); \
24 c2 = a2 * (ONE + ZEROI); \
25 CHECK_RES (c2, COPY, SR, SI); \
26 } while (0)
28 #define CHECK_MUL(TYPE, COPY, ZERO, ZEROI, ONE) \
29 do { \
30 CHECK_MUL_INT (TYPE, COPY, ZERO, ZEROI, ONE, +, +, +, +); \
31 CHECK_MUL_INT (TYPE, COPY, ZERO, ZEROI, ONE, +, -, +, +); \
32 CHECK_MUL_INT (TYPE, COPY, ZERO, ZEROI, ONE, -, +, -, +); \
33 CHECK_MUL_INT (TYPE, COPY, ZERO, ZEROI, ONE, -, -, +, -); \
34 } while (0)
36 void
37 check_mul_float (void)
39 CHECK_MUL (float, __builtin_copysignf, 0.0f, 0.0if, 1.0f);
42 void
43 check_mul_double (void)
45 CHECK_MUL (double, __builtin_copysign, 0.0, 0.0i, 1.0);
48 void
49 check_mul_long_double (void)
51 CHECK_MUL (long double, __builtin_copysignl, 0.0l, 0.0il, 1.0l);
54 int
55 main (void)
57 check_mul_float ();
58 check_mul_double ();
59 check_mul_long_double ();
60 exit (0);