2014-07-29 Ed Smith-Rowland <3dw4rd@verizon.net>
[official-gcc.git] / gcc / testsuite / gcc.dg / cdce2.c
bloba461ce7ac3088e45e384f4cf6c636626ee3dff0c
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-final { scan-tree-dump "cdce2.c:16: note: function call is shrink-wrapped into error conditions\." "cdce" } }*/
5 /* { dg-final { cleanup-tree-dump "cdce" } } */
7 #include <stdlib.h>
8 #include <math.h>
9 #include <errno.h>
10 int total_err_count = 0;
11 double foo_opt (double y) __attribute__((noinline));
12 double foo_opt (double y)
14 double yy = 0;
15 errno = 0;
16 yy = log (y);
17 return 0;
20 double foo (double y) __attribute__((noinline));
21 double foo (double y)
23 double yy = 0;
24 errno = 0;
25 yy = log (y);
26 return yy;
29 int test (double (*fp) (double y))
31 int i,x;
32 for (i = -100; i < 100; i++)
34 fp (i);
35 if (errno)
36 total_err_count ++;
39 return total_err_count;
42 int main ()
44 int en1, en2;
45 double yy;
46 total_err_count = 0;
47 en1 = test (foo_opt);
48 total_err_count = 0;
49 en2 = test (foo);
51 if (en1 != en2)
52 abort();
54 return 0;