2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / gcc.misc-tests / gcov-8.c
blob7223bde8374cd9172efbed749fc7bbb6f1e27b15
1 /* Check that gcov correctly rounds nearly zero to nonzero and nearly
2 100 to not-100.
4 Copyright (C) 2002 Free Software Foundation, Inc.
5 Contributed by Nathan Sidwell <nathan@codesourcery.com>
6 */
8 /* { dg-options "-fprofile-arcs -ftest-coverage" } */
9 /* { dg-do run { target native } } */
11 int proxy (int i)
13 return i;
16 int foo (int i)
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);
26 int baz (int i)
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);
36 int main ()
38 int t = 0;
39 int ix;
41 for (ix = 0; ix != 1000; ix++)
42 t += foo (ix) + baz (ix);
44 return t == 0;
47 /* { dg-final { run-gcov branches {-b gcov-8.c } } } */