1 /* Check that gcov correctly rounds nearly zero to nonzero and nearly
2 100 to not-100.
3
4 Copyright (C) 2002 Free Software Foundation, Inc.
5 Contributed by Nathan Sidwell <nathan@codesourcery.com>
6 */
7
8 /* { dg-options "-fprofile-arcs -ftest-coverage" } */
9 /* { dg-do run { target native } } */
10
proxy(int i)11 int proxy (int i)
12 {
13 return i;
14 }
15
foo(int i)16 int foo (int i)
17 {
18 if (i > 0) /* branch(1) */
19 return proxy (1);
20 else if (i < 0) /* branch(100) */
21 return proxy (-1);
22 else
23 return proxy (0);
24 }
25
baz(int i)26 int baz (int i)
27 {
28 if (i == 0) /* branch(99) */
29 return proxy (0);
30 else if (i > 0) /* branch(0)*/
31 return proxy (1);
32 else
33 return proxy (-1);
34 }
35
main()36 int main ()
37 {
38 int t = 0;
39 int ix;
40
41 for (ix = 0; ix != 1000; ix++)
42 t += foo (ix) + baz (ix);
43
44 return t == 0;
45 }
46
47 /* { dg-final { run-gcov branches {-b gcov-8.c } } } */
48