Merge from mainline.
[official-gcc.git] / gcc / testsuite / gcc.dg / 20030804-1.c
blobcbc66474a5e56dfd56bae2185273336b1c3a058a
1 /* Copyright (C) 2003 Free Software Foundation.
3 Check that constant folding of mathematical expressions doesn't
4 break anything.
6 Written by Roger Sayle, 3rd August 2003. */
8 /* { dg-do link } */
9 /* { dg-options "-O2 -ffast-math" } */
11 extern void link_error(void);
13 void test(double x)
15 if (x+x != 2.0*x)
16 link_error ();
17 if (x+x != x*2.0)
18 link_error ();
20 if (x+x+x != 3.0*x)
21 link_error ();
22 if (x+x+x != x*3.0)
23 link_error ();
25 if ((x+x)+x != 3.0*x)
26 link_error ();
27 if ((x+x)+x != x*3.0)
28 link_error ();
30 if (x+(x+x) != 3.0*x)
31 link_error ();
32 if (x+(x+x) != x*3.0)
33 link_error ();
35 if (x+4.0*x != 5.0*x)
36 link_error ();
37 if (x+4.0*x != x*5.0)
38 link_error ();
39 if (x+x*4.0 != 5.0*x)
40 link_error ();
41 if (x+x*4.0 != x*5.0)
42 link_error ();
43 if (4.0*x+x != 5.0*x)
44 link_error ();
45 if (4.0*x+x != x*5.0)
46 link_error ();
47 if (x*4.0+x != 5.0*x)
48 link_error ();
49 if (x*4.0+x != x*5.0)
50 link_error ();
52 if (3.0*x + 5.0*x != 8.0*x)
53 link_error ();
54 if (3.0*x + 5.0*x != x*8.0)
55 link_error ();
56 if (x*3.0 + 5.0*x != 8.0*x)
57 link_error ();
58 if (x*3.0 + 5.0*x != x*8.0)
59 link_error ();
60 if (3.0*x + x*5.0 != 8.0*x)
61 link_error ();
62 if (3.0*x + x*5.0 != x*8.0)
63 link_error ();
64 if (x*3.0 + x*5.0 != 8.0*x)
65 link_error ();
66 if (x*3.0 + x*5.0 != x*8.0)
67 link_error ();
70 int main()
72 test(2.0);
73 return 0;