summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/torture/pr52451.c
blob: 3f1580d56ee1a5acd6806f834a2b443cb480079a (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
56
57
58
59
60
/* { dg-do run } */
/* { dg-add-options ieee } */
/* { dg-require-effective-target fenv_exceptions } */
/* { dg-skip-if "fenv" { powerpc-ibm-aix* } } */

#include <fenv.h>

#define TEST_C_NOEX(CMP, S)			\
  r = nan##S CMP arg##S;			\
  if (fetestexcept (FE_INVALID))		\
    __builtin_abort ()

#define TEST_B_NOEX(FN, S)			\
  r = __builtin_##FN (nan##S, arg##S);		\
  if (fetestexcept (FE_INVALID))		\
    __builtin_abort ()

#define TEST_C_EX(CMP, S)			\
  r = nan##S CMP arg##S;			\
  if (!fetestexcept (FE_INVALID))		\
    __builtin_abort ();				\
  feclearexcept (FE_INVALID)

#define TEST(TYPE, S)				\
  volatile TYPE nan##S = __builtin_nan##S ("");	\
  volatile TYPE arg##S = 1.0##S;		\
						\
  TEST_C_NOEX (==, S);				\
  TEST_C_NOEX (!=, S);				\
						\
  TEST_B_NOEX (isgreater, S);			\
  TEST_B_NOEX (isless, S);			\
  TEST_B_NOEX (isgreaterequal, S);		\
  TEST_B_NOEX (islessequal, S);			\
						\
  TEST_B_NOEX (islessgreater, S);		\
  TEST_B_NOEX (isunordered, S);			\
						\
  TEST_C_EX (>, S);				\
  TEST_C_EX (<, S);				\
  TEST_C_EX (>=, S);				\
  TEST_C_EX (<=, S)

int
main (void)
{
  volatile int r;

  feclearexcept (FE_INVALID);

  TEST (float, f);
  TEST (double, );
#if !defined(__hppa__) || !defined(__hpux__)
  /* Long double on hppa*-hpux* is implemented in software and the routines
     in fenv.h do not support it.  */
  TEST (long double, l);
#endif
  
  return 0;
}