| 1 |
/* Test SNAN macros. Runtime exceptions test, to verify NaN is |
| 2 |
signaling. */ |
| 3 |
/* { dg-do run } */ |
| 4 |
/* { dg-require-effective-target fenv_exceptions } */ |
| 5 |
/* { dg-options "-std=c23 -pedantic-errors -fsignaling-nans" } */ |
| 6 |
/* { dg-add-options ieee } */ |
| 7 |
|
| 8 |
#include <fenv.h> |
| 9 |
#include <float.h> |
| 10 |
|
| 11 |
/* This should be defined if and only if signaling NaNs is supported |
| 12 |
for the given type. If the testsuite gains effective-target |
| 13 |
support for targets not supporting signaling NaNs, this test |
| 14 |
should be made appropriately conditional. */ |
| 15 |
#ifndef FLT_SNAN |
| 16 |
#error "FLT_SNAN undefined" |
| 17 |
#endif |
| 18 |
|
| 19 |
volatile float f = FLT_SNAN; |
| 20 |
|
| 21 |
extern void abort (void); |
| 22 |
extern void exit (int); |
| 23 |
|
| 24 |
int |
| 25 |
main (void) |
| 26 |
{ |
| 27 |
feclearexcept (FE_ALL_EXCEPT); |
| 28 |
f += f; |
| 29 |
if (!fetestexcept (FE_INVALID)) |
| 30 |
abort (); |
| 31 |
exit (0); |
| 32 |
} |