summaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common/torture/complex-sign-sub.c
blob: 0a4e3029e685d640b0c277efa3ca1ed60263d8c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* Test complex arithmetic with signed zeros.  Pure complex
   subtraction.  */
/* { dg-do run } */
/* { dg-options "-std=gnu99" { target c } } */

#include "complex-sign.h"

#define CHECK_SUB(TYPE, COPY, ZERO, ZEROI)			\
  do {								\
    CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, +, +, +, +, +, +);	\
    CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, +, +, +, -, +, +);	\
    CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, +, +, -, +, +, +);	\
    CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, +, +, -, -, +, +);	\
    CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, +, -, +, +, +, -);	\
    CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, +, -, +, -, +, +);	\
    CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, +, -, -, +, +, -);	\
    CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, +, -, -, -, +, +);	\
    CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, -, +, +, +, -, +);	\
    CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, -, +, +, -, -, +);	\
    CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, -, +, -, +, +, +);	\
    CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, -, +, -, -, +, +);	\
    CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, -, -, +, +, -, -);	\
    CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, -, -, +, -, -, +);	\
    CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, -, -, -, +, +, -);	\
    CHECK_ARITH (TYPE, COPY, ZERO, ZEROI, -, -, -, -, -, +, +);	\
  } while (0)

void
check_sub_float (void)
{
#ifndef __SPU__
  CHECK_SUB (float, __builtin_copysignf, 0.0f, 0.0if);
#endif
}

void
check_sub_double (void)
{
  CHECK_SUB (double, __builtin_copysign, 0.0, 0.0i);
}

void
check_sub_long_double (void)
{
  CHECK_SUB (long double, __builtin_copysignl, 0.0l, 0.0il);
}

int
main (void)
{
  check_sub_float ();
  check_sub_double ();
  check_sub_long_double ();
  exit (0);
}