| 1 |
/* { dg-do run { target { *-*-linux* *-*-gnu* } } } */ |
| 2 |
/* { dg-options "-O1 -lm -fexcess-precision=standard -fsignaling-nans" } */ |
| 3 |
/* { dg-add-options ieee } */ |
| 4 |
/* { dg-require-effective-target issignaling } */ |
| 5 |
|
| 6 |
#define _GNU_SOURCE |
| 7 |
#include <stdio.h> |
| 8 |
#include <math.h> |
| 9 |
|
| 10 |
void conversion() |
| 11 |
{ |
| 12 |
float sNaN = __builtin_nansf (""); |
| 13 |
double x = (double) sNaN; |
| 14 |
if (issignaling(x)) |
| 15 |
{ |
| 16 |
__builtin_abort(); |
| 17 |
} |
| 18 |
} |
| 19 |
|
| 20 |
enum op {Add, Mult, Div, Abs}; |
| 21 |
|
| 22 |
void operation(enum op t) |
| 23 |
{ |
| 24 |
float x, y; |
| 25 |
float sNaN = __builtin_nansf (""); |
| 26 |
switch (t) |
| 27 |
{ |
| 28 |
case Abs: |
| 29 |
x = fabs(sNaN); |
| 30 |
break; |
| 31 |
case Add: |
| 32 |
x = sNaN + 2.0; |
| 33 |
break; |
| 34 |
case Mult: |
| 35 |
x = sNaN * 2.0; |
| 36 |
break; |
| 37 |
case Div: |
| 38 |
default: |
| 39 |
x = sNaN / 2.0; |
| 40 |
break; |
| 41 |
} |
| 42 |
if (t == Abs) |
| 43 |
{ |
| 44 |
if (!issignaling(x)) |
| 45 |
{ |
| 46 |
__builtin_abort(); |
| 47 |
} |
| 48 |
} |
| 49 |
else if (issignaling(x)) |
| 50 |
{ |
| 51 |
__builtin_abort(); |
| 52 |
} |
| 53 |
} |
| 54 |
|
| 55 |
int main (void) |
| 56 |
{ |
| 57 |
conversion(); |
| 58 |
operation(Add); |
| 59 |
operation(Mult); |
| 60 |
operation(Div); |
| 61 |
#if __FLT_EVAL_METHOD__ == 0 |
| 62 |
operation(Abs); |
| 63 |
#endif |
| 64 |
return 0; |
| 65 |
} |