OSDN Git Service

libcpp:
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / cdce2.c
1 /* { dg-do  run  } */
2 /* { dg-skip-if "doubles are floats" { "avr-*-*" } { "*" } { "" } } */
3 /* { dg-options "-O2 -fmath-errno -fdump-tree-cdce-details  -lm" } */
4 /* { dg-options "-O2 -fmath-errno -fdump-tree-cdce-details" { target *-*-netware* } } */
5 /* { dg-final { scan-tree-dump  "cdce2.c:17: note: function call is shrink-wrapped into error conditions\." "cdce" } }*/
6 /* { dg-final { cleanup-tree-dump "cdce" } } */
7  
8 #include <stdlib.h>
9 #include <math.h>
10 #include <errno.h>
11 int total_err_count = 0;
12 double foo_opt (double y) __attribute__((noinline));
13 double foo_opt (double y)
14 {
15   double yy = 0;
16   errno = 0;
17   yy = log (y);
18   return 0;
19 }
20
21 double foo (double y) __attribute__((noinline));
22 double foo (double y)
23 {
24   double yy = 0;
25   errno = 0;
26   yy = log (y);
27   return yy;
28 }
29
30 int test (double (*fp) (double y))
31 {
32   int i,x;
33   for (i = -100; i < 100; i++)
34     {  
35       fp (i);
36       if (errno)
37         total_err_count ++;
38     }
39
40   return total_err_count;
41 }
42
43 int main ()
44 {
45   int en1, en2;
46   double yy;
47   total_err_count = 0;
48   en1 = test (foo_opt);
49   total_err_count = 0;
50   en2 = test (foo);
51
52   if (en1 != en2)
53     abort();
54
55   return 0;
56 }