2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / gcc.dg / torture / builtin-math-1.c
blob47b91d7e25d7e4aab3a8e8d6c0686b1bd2aad756
1 /* Copyright (C) 2002, 2003 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 } */
10 /* All references to link_error should go away at compile-time. */
11 extern void link_error(void);
13 void test (float f, double d, long double ld)
15 if (sqrt (0.0) != 0.0)
16 link_error ();
18 if (sqrt (1.0) != 1.0)
19 link_error ();
21 if (exp (0.0) != 1.0)
22 link_error ();
24 if (exp (1.0) <= 2.71 || exp (1.0) >= 2.72)
25 link_error ();
27 if (log (1.0) != 0.0)
28 link_error ();
30 if (sin (0.0) != 0.0)
31 link_error ();
33 if (cos (0.0) != 1.0)
34 link_error ();
36 if (tan (0.0) != 0.0)
37 link_error ();
39 if (atan (0.0) != 0.0)
40 link_error ();
42 if (4.0*atan (1.0) <= 3.14 || 4.0*atan (1.0) >= 3.15)
43 link_error ();
45 if (pow (d, 0.0) != 1.0)
46 link_error ();
48 if (pow (1.0, d) != 1.0)
49 link_error ();
52 if (sqrtf (0.0F) != 0.0F)
53 link_error ();
55 if (sqrtf (1.0F) != 1.0F)
56 link_error ();
58 if (expf (0.0F) != 1.0F)
59 link_error ();
61 if (expf (1.0F) <= 2.71F || expf (1.0F) >= 2.72F)
62 link_error ();
64 if (logf (1.0F) != 0.0F)
65 link_error ();
67 if (sinf (0.0F) != 0.0F)
68 link_error ();
70 if (cosf (0.0F) != 1.0F)
71 link_error ();
73 if (tanf (0.0F) != 0.0F)
74 link_error ();
76 if (atanf (0.0F) != 0.0F)
77 link_error ();
79 if (4.0F*atanf (1.0F) <= 3.14F || 4.0F*atanf (1.0F) >= 3.15F)
80 link_error ();
82 if (powf (f, 0.0F) != 1.0F)
83 link_error ();
85 if (powf (1.0F, f) != 1.0F)
86 link_error ();
89 if (sqrtl (0.0L) != 0.0L)
90 link_error ();
92 if (sqrtl (1.0L) != 1.0L)
93 link_error ();
95 if (expl (0.0L) != 1.0L)
96 link_error ();
98 if (expl (1.0L) <= 2.71L || expl (1.0L) >= 2.72L)
99 link_error ();
101 if (logl (1.0L) != 0.0L)
102 link_error ();
104 if (sinl (0.0L) != 0.0L)
105 link_error ();
107 if (cosl (0.0L) != 1.0L)
108 link_error ();
110 if (tanl (0.0L) != 0.0L)
111 link_error ();
113 if (atanl (0.0) != 0.0L)
114 link_error ();
116 if (4.0L*atanl (1.0L) <= 3.14L || 4.0L*atanl (1.0L) >= 3.15L)
117 link_error ();
119 if (powl (ld, 0.0L) != 1.0L)
120 link_error ();
122 if (powl (1.0L, ld) != 1.0L)
123 link_error ();
126 int main()
128 test (3.0, 3.0F, 3.0L);
130 return 0;