aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/dfp/builtin-snan-2.c
blob: 248481bd371b80a6694c5787c7ac735567dd6a1c (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
/* Test __builtin_nansd* functions.  Test requiring runtime exceptions
   support.  */
/* { dg-do run } */
/* { dg-require-effective-target fenv_exceptions_dfp } */
/* { dg-options "" } */

#include <fenv.h>

volatile _Decimal32 d32 = __builtin_nansd32 ("");
volatile _Decimal64 d64 = __builtin_nansd64 ("");
volatile _Decimal128 d128 = __builtin_nansd128 ("");

extern void abort (void);
extern void exit (int);

int
main (void)
{
  feclearexcept (FE_ALL_EXCEPT);
  d32 += d32;
  if (!fetestexcept (FE_INVALID))
    abort ();
  feclearexcept (FE_ALL_EXCEPT);
  d32 += d32;
  if (fetestexcept (FE_INVALID))
    abort ();
  feclearexcept (FE_ALL_EXCEPT);
  d64 += d64;
  if (!fetestexcept (FE_INVALID))
    abort ();
  feclearexcept (FE_ALL_EXCEPT);
  d64 += d64;
  if (fetestexcept (FE_INVALID))
    abort ();
  feclearexcept (FE_ALL_EXCEPT);
  d128 += d128;
  if (!fetestexcept (FE_INVALID))
    abort ();
  feclearexcept (FE_ALL_EXCEPT);
  d128 += d128;
  if (fetestexcept (FE_INVALID))
    abort ();
  exit (0);
}