1 /* Copyright (C) 2003 Free Software Foundation. 2 3 Verify that built-in math function constant folding of constant 4 arguments is correctly performed by the by the compiler. 5 6 Written by Roger Sayle, 30th March 2003. */ 7 8 /* { dg-do link } */ 9 /* { dg-options "-O2 -ffast-math" } */ 10 11 extern double pow (double, double); 12 extern float powf (float, float); 13 extern long double powl (long double, long double); 14 extern double tan (double); 15 extern float tanf (float); 16 extern long double tanl (long double); 17 extern double atan (double); 18 extern float atanf (float); 19 extern long double atanl (long double); 20 21 extern void link_error(void); 22 test(double x)23void test(double x) 24 { 25 if (pow (x, 1.0) != x) 26 link_error (); 27 if (tan (atan (x)) != x) 28 link_error (); 29 } 30 testf(float x)31void testf(float x) 32 { 33 if (powf (x, 1.0f) != x) 34 link_error (); 35 if (tanf (atanf (x)) != x) 36 link_error (); 37 } 38 testl(long double x)39void testl(long double x) 40 { 41 if (powl (x, 1.0l) != x) 42 link_error (); 43 if (tanl (atanl (x)) != x) 44 link_error (); 45 } 46 main()47int main() 48 { 49 test (2.0); 50 testf (2.0f); 51 testl (2.0l); 52 53 return 0; 54 } 55 56