| 1 |
/* Tests for _FloatN / _FloatNx types: compile and execution tests for |
| 2 |
NaNs. Before including this file, define WIDTH as the value N; |
| 3 |
define EXT to 1 for _FloatNx and 0 for _FloatN. */ |
| 4 |
|
| 5 |
#define CONCATX(X, Y) X ## Y |
| 6 |
#define CONCAT(X, Y) CONCATX (X, Y) |
| 7 |
#define CONCAT3(X, Y, Z) CONCAT (CONCAT (X, Y), Z) |
| 8 |
#define CONCAT4(W, X, Y, Z) CONCAT (CONCAT (CONCAT (W, X), Y), Z) |
| 9 |
|
| 10 |
#if EXT |
| 11 |
# define TYPE CONCAT3 (_Float, WIDTH, x) |
| 12 |
# define CST(C) CONCAT4 (C, f, WIDTH, x) |
| 13 |
# define FN(F) CONCAT4 (F, f, WIDTH, x) |
| 14 |
#else |
| 15 |
# define TYPE CONCAT (_Float, WIDTH) |
| 16 |
# define CST(C) CONCAT3 (C, f, WIDTH) |
| 17 |
# define FN(F) CONCAT3 (F, f, WIDTH) |
| 18 |
#endif |
| 19 |
|
| 20 |
#include <fenv.h> |
| 21 |
|
| 22 |
extern void exit (int); |
| 23 |
extern void abort (void); |
| 24 |
|
| 25 |
volatile TYPE nan_cst = FN (__builtin_nan) (""); |
| 26 |
volatile TYPE nans_cst = FN (__builtin_nans) (""); |
| 27 |
|
| 28 |
int |
| 29 |
main (void) |
| 30 |
{ |
| 31 |
volatile TYPE r; |
| 32 |
r = nan_cst + nan_cst; |
| 33 |
if (fetestexcept (FE_INVALID)) |
| 34 |
abort (); |
| 35 |
r = nans_cst + nans_cst; |
| 36 |
if (!fetestexcept (FE_INVALID)) |
| 37 |
abort (); |
| 38 |
exit (0); |
| 39 |
} |