1 /* Copyright (C) 2002, 2003, 2004 Free Software Foundation.
3 Verify that built-in math function constant folding of constant
4 arguments is correctly performed by the compiler.
6 Written by Roger Sayle, 16th August 2002. */
10 extern double atan (double);
11 extern float atanf (float);
12 extern long double atanl (long double);
13 extern double cbrt (double);
14 extern float cbrtf (float);
15 extern long double cbrtl (long double);
16 extern double cos (double);
17 extern float cosf (float);
18 extern long double cosl (long double);
19 extern double exp (double);
20 extern float expf (float);
21 extern long double expl (long double);
22 extern double log (double);
23 extern float logf (float);
24 extern long double logl (long double);
25 extern double pow (double, double);
26 extern float powf (float, float);
27 extern long double powl (long double, long double);
28 extern double sin (double);
29 extern float sinf (float);
30 extern long double sinl (long double);
31 extern double sqrt (double);
32 extern float sqrtf (float);
33 extern long double sqrtl (long double);
34 extern double tan (double);
35 extern float tanf (float);
36 extern long double tanl (long double);
38 /* All references to link_error should go away at compile-time. */
39 extern void link_error(void);
41 void test (float f, double d, long double ld)
43 if (sqrt (0.0) != 0.0)
46 if (sqrt (1.0) != 1.0)
49 if (cbrt (0.0) != 0.0)
52 if (cbrt (1.0) != 1.0)
55 if (cbrt (-1.0) != -1.0)
61 if (exp (1.0) <= 2.71 || exp (1.0) >= 2.72)
76 if (atan (0.0) != 0.0)
79 if (4.0*atan (1.0) <= 3.14 || 4.0*atan (1.0) >= 3.15)
82 if (pow (d, 0.0) != 1.0)
85 if (pow (1.0, d) != 1.0)
89 if (sqrtf (0.0F) != 0.0F)
92 if (sqrtf (1.0F) != 1.0F)
95 if (cbrtf (0.0F) != 0.0F)
98 if (cbrtf (1.0F) != 1.0F)
101 if (cbrtf (-1.0F) != -1.0F)
104 if (expf (0.0F) != 1.0F)
107 if (expf (1.0F) <= 2.71F || expf (1.0F) >= 2.72F)
110 if (logf (1.0F) != 0.0F)
113 if (sinf (0.0F) != 0.0F)
116 if (cosf (0.0F) != 1.0F)
119 if (tanf (0.0F) != 0.0F)
122 if (atanf (0.0F) != 0.0F)
125 if (4.0F*atanf (1.0F) <= 3.14F || 4.0F*atanf (1.0F) >= 3.15F)
128 if (powf (f, 0.0F) != 1.0F)
131 if (powf (1.0F, f) != 1.0F)
135 if (sqrtl (0.0L) != 0.0L)
138 if (sqrtl (1.0L) != 1.0L)
141 if (cbrtl (0.0L) != 0.0L)
144 if (cbrtl (1.0L) != 1.0L)
147 if (cbrtl (-1.0L) != -1.0L)
150 if (expl (0.0L) != 1.0L)
153 if (expl (1.0L) <= 2.71L || expl (1.0L) >= 2.72L)
156 if (logl (1.0L) != 0.0L)
159 if (sinl (0.0L) != 0.0L)
162 if (cosl (0.0L) != 1.0L)
165 if (tanl (0.0L) != 0.0L)
168 if (atanl (0.0) != 0.0L)
171 if (4.0L*atanl (1.0L) <= 3.14L || 4.0L*atanl (1.0L) >= 3.15L)
174 if (powl (ld, 0.0L) != 1.0L)
177 if (powl (1.0L, ld) != 1.0L)
183 test (3.0, 3.0F, 3.0L);