pr79732.c: Require alias support.
[official-gcc.git] / gcc / testsuite / gcc.dg / torture / builtin-math-1.c
blob4ecc98d5f5c350e8727c9586bc72dcc6d580df71
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. */
8 /* { dg-do link } */
9 /* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
11 extern double atan (double);
12 extern float atanf (float);
13 extern long double atanl (long double);
14 extern double cbrt (double);
15 extern float cbrtf (float);
16 extern long double cbrtl (long double);
17 extern double cos (double);
18 extern float cosf (float);
19 extern long double cosl (long double);
20 extern double exp (double);
21 extern float expf (float);
22 extern long double expl (long double);
23 extern double log (double);
24 extern float logf (float);
25 extern long double logl (long double);
26 extern double pow (double, double);
27 extern float powf (float, float);
28 extern long double powl (long double, long double);
29 extern double sin (double);
30 extern float sinf (float);
31 extern long double sinl (long double);
32 extern double sqrt (double);
33 extern float sqrtf (float);
34 extern long double sqrtl (long double);
35 extern double tan (double);
36 extern float tanf (float);
37 extern long double tanl (long double);
39 /* All references to link_error should go away at compile-time. */
40 extern void link_error(void);
42 void test (float f, double d, long double ld)
44 if (sqrt (0.0) != 0.0)
45 link_error ();
47 if (sqrt (1.0) != 1.0)
48 link_error ();
50 if (cbrt (0.0) != 0.0)
51 link_error ();
53 if (cbrt (1.0) != 1.0)
54 link_error ();
56 if (cbrt (-1.0) != -1.0)
57 link_error ();
59 if (exp (0.0) != 1.0)
60 link_error ();
62 if (exp (1.0) <= 2.71 || exp (1.0) >= 2.72)
63 link_error ();
65 if (log (1.0) != 0.0)
66 link_error ();
68 if (sin (0.0) != 0.0)
69 link_error ();
71 if (cos (0.0) != 1.0)
72 link_error ();
74 if (tan (0.0) != 0.0)
75 link_error ();
77 if (atan (0.0) != 0.0)
78 link_error ();
80 if (4.0*atan (1.0) <= 3.14 || 4.0*atan (1.0) >= 3.15)
81 link_error ();
83 if (pow (d, 0.0) != 1.0)
84 link_error ();
86 if (pow (1.0, d) != 1.0)
87 link_error ();
90 if (sqrtf (0.0F) != 0.0F)
91 link_error ();
93 if (sqrtf (1.0F) != 1.0F)
94 link_error ();
96 if (cbrtf (0.0F) != 0.0F)
97 link_error ();
99 if (cbrtf (1.0F) != 1.0F)
100 link_error ();
102 if (cbrtf (-1.0F) != -1.0F)
103 link_error ();
105 if (expf (0.0F) != 1.0F)
106 link_error ();
108 if (expf (1.0F) <= 2.71F || expf (1.0F) >= 2.72F)
109 link_error ();
111 if (logf (1.0F) != 0.0F)
112 link_error ();
114 if (sinf (0.0F) != 0.0F)
115 link_error ();
117 if (cosf (0.0F) != 1.0F)
118 link_error ();
120 if (tanf (0.0F) != 0.0F)
121 link_error ();
123 if (atanf (0.0F) != 0.0F)
124 link_error ();
126 if (4.0F*atanf (1.0F) <= 3.14F || 4.0F*atanf (1.0F) >= 3.15F)
127 link_error ();
129 if (powf (f, 0.0F) != 1.0F)
130 link_error ();
132 if (powf (1.0F, f) != 1.0F)
133 link_error ();
136 if (sqrtl (0.0L) != 0.0L)
137 link_error ();
139 if (sqrtl (1.0L) != 1.0L)
140 link_error ();
142 if (cbrtl (0.0L) != 0.0L)
143 link_error ();
145 if (cbrtl (1.0L) != 1.0L)
146 link_error ();
148 if (cbrtl (-1.0L) != -1.0L)
149 link_error ();
151 if (expl (0.0L) != 1.0L)
152 link_error ();
154 if (expl (1.0L) <= 2.71L || expl (1.0L) >= 2.72L)
155 link_error ();
157 if (logl (1.0L) != 0.0L)
158 link_error ();
160 if (sinl (0.0L) != 0.0L)
161 link_error ();
163 if (cosl (0.0L) != 1.0L)
164 link_error ();
166 if (tanl (0.0L) != 0.0L)
167 link_error ();
169 if (atanl (0.0) != 0.0L)
170 link_error ();
172 if (4.0L*atanl (1.0L) <= 3.14L || 4.0L*atanl (1.0L) >= 3.15L)
173 link_error ();
175 if (powl (ld, 0.0L) != 1.0L)
176 link_error ();
178 if (powl (1.0L, ld) != 1.0L)
179 link_error ();
182 int main()
184 test (3.0, 3.0F, 3.0L);
186 return 0;