1 /* { dg-do link } */
2 /* { dg-options "-ffast-math" } */
3 /* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
4
5 extern double sqrt (double);
6 extern float sqrtf (float);
7 extern long double sqrtl (long double);
8
9 /* All references to link_error should go away at compile-time. */
10 extern void link_error (void);
11
12 #define TEST_ONE(SUFFIX, TYPE) \
13 void __attribute__ ((noinline, noclone)) \
14 test##SUFFIX (TYPE f, int *res) \
15 { \
16 TYPE sqrt_res = sqrt##SUFFIX (f); \
17 res[0] = sqrt_res < 0; \
18 if (res[0]) \
19 link_error (); \
20 res[1] = sqrt_res <= 0; \
21 if (res[1] != (f == 0)) \
22 link_error (); \
23 res[2] = (sqrt_res == 0); \
24 if (res[2] != (f == 0)) \
25 link_error (); \
26 res[3] = (sqrt_res != 0); \
27 if (res[3] != (f != 0)) \
28 link_error (); \
29 res[4] = (sqrt_res > 0); \
30 if (res[4] != (f > 0)) \
31 link_error (); \
32 res[5] = (sqrt_res >= 0); \
33 if (!res[5]) \
34 link_error (); \
35 }
36
37 volatile float f;
38 volatile double d;
39 volatile long double ld;
40
TEST_ONE(f,float)41 TEST_ONE (f, float)
42 TEST_ONE (, double)
43 TEST_ONE (l, long double)
44
45 int
46 main ()
47 {
48 int res[6];
49 testf (f, res);
50 test (d, res);
51 testl (ld, res);
52 return 0;
53 }
54