aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/c23-float-7a.c
blob: 305494987191af0737f032cef3f9fcfd4c50f0e5 (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
/* Test SNAN macros.  Runtime exceptions test, to verify NaN is
   signaling.  */
/* { dg-do run } */
/* { dg-require-effective-target fenv_exceptions } */
/* { dg-options "-std=c23 -pedantic-errors -fsignaling-nans" } */
/* { dg-add-options ieee } */

#include <fenv.h>
#include <float.h>

/* This should be defined if and only if signaling NaNs is supported
   for the given type.  If the testsuite gains effective-target
   support for targets not supporting signaling NaNs, this test
   should be made appropriately conditional.  */
#ifndef FLT_SNAN
#error "FLT_SNAN undefined"
#endif

volatile float f = FLT_SNAN;

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

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