Mercurial > hg > CbC > CbC_gcc
comparison gcc/testsuite/gcc.dg/20030804-1.c @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
68:561a7518be6b | 111:04ced10e8804 |
---|---|
1 /* Copyright (C) 2003 Free Software Foundation. | |
2 | |
3 Check that constant folding of mathematical expressions doesn't | |
4 break anything. | |
5 | |
6 Written by Roger Sayle, 3rd August 2003. */ | |
7 | |
8 /* { dg-do link } */ | |
9 /* { dg-options "-O2 -ffast-math" } */ | |
10 | |
11 extern void link_error(void); | |
12 | |
13 void test(double x) | |
14 { | |
15 if (x+x != 2.0*x) | |
16 link_error (); | |
17 if (x+x != x*2.0) | |
18 link_error (); | |
19 | |
20 if (x+x+x != 3.0*x) | |
21 link_error (); | |
22 if (x+x+x != x*3.0) | |
23 link_error (); | |
24 | |
25 if ((x+x)+x != 3.0*x) | |
26 link_error (); | |
27 if ((x+x)+x != x*3.0) | |
28 link_error (); | |
29 | |
30 if (x+(x+x) != 3.0*x) | |
31 link_error (); | |
32 if (x+(x+x) != x*3.0) | |
33 link_error (); | |
34 | |
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 (); | |
51 | |
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 (); | |
68 } | |
69 | |
70 int main() | |
71 { | |
72 test(2.0); | |
73 return 0; | |
74 } | |
75 |