| 1 |
/* Copyright (C) 2004 Free Software Foundation. |
| 2 |
|
| 3 |
Check that constant folding of copysign, copysignf and copysignl math |
| 4 |
functions doesn't break anything and produces the expected results. |
| 5 |
|
| 6 |
Written by Roger Sayle, 6th June 2004. */ |
| 7 |
|
| 8 |
/* { dg-do link } */ |
| 9 |
/* { dg-options "-O2" } */ |
| 10 |
|
| 11 |
extern void link_error(void); |
| 12 |
|
| 13 |
extern double copysign(double, double); |
| 14 |
extern float copysignf(float, float); |
| 15 |
extern long double copysignl(long double, long double); |
| 16 |
|
| 17 |
int main() |
| 18 |
{ |
| 19 |
if (copysign (2.0, 1.0) != 2.0) |
| 20 |
link_error (); |
| 21 |
if (copysign (2.0, -1.0) != -2.0) |
| 22 |
link_error (); |
| 23 |
if (copysign (-2.0, 1.0) != 2.0) |
| 24 |
link_error (); |
| 25 |
if (copysign (-2.0, -1.0) != -2.0) |
| 26 |
link_error (); |
| 27 |
|
| 28 |
if (copysign (2.0, 1.0) != 2.0) |
| 29 |
link_error (); |
| 30 |
if (copysign (2.0, -1.0) != -2.0) |
| 31 |
link_error (); |
| 32 |
if (copysign (-2.0, 1.0) != 2.0) |
| 33 |
link_error (); |
| 34 |
if (copysign (-2.0, -1.0) != -2.0) |
| 35 |
link_error (); |
| 36 |
|
| 37 |
if (copysignf (2.0f, 1.0f) != 2.0f) |
| 38 |
link_error (); |
| 39 |
if (copysignf (2.0f, -1.0f) != -2.0f) |
| 40 |
link_error (); |
| 41 |
if (copysignf (-2.0f, 1.0f) != 2.0f) |
| 42 |
link_error (); |
| 43 |
if (copysignf (-2.0f, -1.0f) != -2.0f) |
| 44 |
link_error (); |
| 45 |
|
| 46 |
if (copysignl (2.0l, 1.0l) != 2.0l) |
| 47 |
link_error (); |
| 48 |
if (copysignl (2.0l, -1.0l) != -2.0l) |
| 49 |
link_error (); |
| 50 |
if (copysignl (-2.0l, 1.0l) != 2.0l) |
| 51 |
link_error (); |
| 52 |
if (copysignl (-2.0l, -1.0l) != -2.0l) |
| 53 |
link_error (); |
| 54 |
|
| 55 |
return 0; |
| 56 |
} |
| 57 |
|