PR debug/48204
[official-gcc.git] / gcc / testsuite / gcc.dg / cdce2.c
blobeebebaa2390f46125e848ed926d8587dbb593e81
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" } } */
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)
15 double yy = 0;
16 errno = 0;
17 yy = log (y);
18 return 0;
21 double foo (double y) __attribute__((noinline));
22 double foo (double y)
24 double yy = 0;
25 errno = 0;
26 yy = log (y);
27 return yy;
30 int test (double (*fp) (double y))
32 int i,x;
33 for (i = -100; i < 100; i++)
35 fp (i);
36 if (errno)
37 total_err_count ++;
40 return total_err_count;
43 int main ()
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);
52 if (en1 != en2)
53 abort();
55 return 0;