Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / gcc / testsuite / gcc.misc-tests / gcov-7.c
blob2e0f6e8b03c1854942ddbe9d0afc3f54968bea33
1 /* Check that gcov correctly reports line counts, branch percentages,
2 * and call return percentages for functions that call longjmp. */
4 /* { dg-options "-fprofile-arcs -ftest-coverage" } */
5 /* { dg-do run { target native } } */
7 #include <setjmp.h>
9 extern void abort (void);
10 extern void exit (int);
12 jmp_buf env;
13 int val;
14 int longjmp_taken;
15 int bar_enter, bar_exit;
16 int foo_enter, foo_exit;
18 void bar (int i)
20 bar_enter++; /* count(3) */
21 /* branch(67) */
22 if (i == 0) {
23 /* branch(end) */
24 longjmp_taken++; /* count(1) */
25 longjmp (env, 1);
27 val += i+1;
28 bar_exit++; /* count(2) */
31 void foo (int i)
33 foo_enter++; /* count(3) */
34 /* branch(67) */
35 if (i == 1) {
36 /* branch(end) */
37 longjmp_taken++; /* count(1) */
38 longjmp (env, 2);
40 /* returns(50) */
41 bar (i); /* count(2) */
42 /* returns(100) */
43 bar (7); /* count(1) */
44 /* returns(end) */
45 val += 16;
46 foo_exit++; /* count(1) */
49 int
50 passed ()
52 return (val == 31 &&
53 longjmp_taken == 2 &&
54 foo_enter == 3 &&
55 foo_exit == 1 &&
56 bar_enter == 3 &&
57 bar_exit == 2);
61 void
62 leave (int i)
64 if (i == 0) {
65 abort ();
67 exit (0);
70 int
71 main()
73 int retval;
75 /* branch(33) */
76 if ((retval = setjmp (env))) {
77 /* branch(end) */
78 val += retval; /* count(2) */
80 /* returns(33) */
81 foo (val); /* count(3) */
82 /* returns(0) */
83 leave (passed()); /* count(1) */
84 /* returns(end) */
87 /* { dg-final { run-gcov calls branches { -b gcov-7.c } } } */