Sync usage with man page.
[netbsd-mini2440.git] / gnu / dist / gcc4 / gcc / testsuite / gcc.dg / builtins-20.c
blobdbcf96c3c07b6440a6068a0bbe4e1bac6669c057
1 /* Copyright (C) 2003 Free Software Foundation.
3 Verify that built-in math function constant folding doesn't break
4 anything and produces the expected results.
6 Written by Roger Sayle, 8th June 2003. */
8 /* { dg-do link } */
9 /* { dg-options "-O2 -ffast-math" } */
10 /* { dg-options "-O2 -ffast-math -mmacosx-version-min=10.3" { target powerpc-*-darwin* } } */
12 #include "builtins-config.h"
14 extern double cos (double);
15 extern double sin (double);
16 extern double tan (double);
17 extern float cosf (float);
18 extern float sinf (float);
19 extern float tanf (float);
20 extern long double cosl (long double);
21 extern long double sinl (long double);
22 extern long double tanl (long double);
24 extern void link_error(void);
26 void test1(double x)
28 if (cos(x) != cos(-x))
29 link_error ();
31 if (sin(x)/cos(x) != tan(x))
32 link_error ();
34 if (cos(x)/sin(x) != 1.0/tan(x))
35 link_error ();
37 if (tan(x)*cos(x) != sin(x))
38 link_error ();
40 if (cos(x)*tan(x) != sin(x))
41 link_error ();
44 void test2(double x, double y)
46 if (-tan(x-y) != tan(y-x))
47 link_error ();
49 if (-sin(x-y) != sin(y-x))
50 link_error ();
53 void test1f(float x)
55 if (cosf(x) != cosf(-x))
56 link_error ();
58 #ifdef HAVE_C99_RUNTIME
59 if (sinf(x)/cosf(x) != tanf(x))
60 link_error ();
62 if (cosf(x)/sinf(x) != 1.0f/tanf(x))
63 link_error ();
65 if (tanf(x)*cosf(x) != sinf(x))
66 link_error ();
68 if (cosf(x)*tanf(x) != sinf(x))
69 link_error ();
70 #endif
73 void test2f(float x, float y)
75 if (-tanf(x-y) != tanf(y-x))
76 link_error ();
78 if (-sinf(x-y) != sinf(y-x))
79 link_error ();
83 void test1l(long double x)
85 if (cosl(x) != cosl(-x))
86 link_error ();
88 #ifdef HAVE_C99_RUNTIME
89 if (sinl(x)/cosl(x) != tanl(x))
90 link_error ();
92 if (cosl(x)/sinl(x) != 1.0l/tanl(x))
93 link_error ();
95 if (tanl(x)*cosl(x) != sinl(x))
96 link_error ();
98 if (cosl(x)*tanl(x) != sinl(x))
99 link_error ();
100 #endif
103 void test2l(long double x, long double y)
105 if (-tanl(x-y) != tanl(y-x))
106 link_error ();
108 if (-sinl(x-y) != sinl(y-x))
109 link_error ();
112 int main()
114 test1 (1.0);
115 test2 (1.0, 2.0);
117 test1f (1.0f);
118 test2f (1.0f, 2.0f);
120 test1l (1.0l);
121 test2l (1.0l, 2.0l);
123 return 0;