aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/analyzer/infinite-recursion-multiline-2.c
blob: 2c69dd508f0df59a23f4441b995105b78e122672 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/* Integration test of how the execution path looks for
   -Wanalyzer-infinite-recursion.  */

/* { dg-additional-options "-fdiagnostics-show-path-depths" } */
/* { dg-additional-options "-fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */

void mutual_2 (void);

void mutual_1 (void)
{
  mutual_2 (); /* { dg-warning "infinite recursion" } */
}

void mutual_2 (void)
{
  mutual_1 (); /* { dg-warning "infinite recursion" } */
}


/* { dg-begin-multiline-output "" }
   mutual_2 ();
   ^~~~~~~~~~~
  'mutual_2': events 1-2 (depth 1)
    |
    | void mutual_2 (void)
    |      ^~~~~~~~
    |      |
    |      (1) initial entry to 'mutual_2'
    |
    |   mutual_1 ();
    |   ~~~~~~~~~~~
    |   |
    |   (2) calling 'mutual_1' from 'mutual_2'
    |
    +--> 'mutual_1': events 3-4 (depth 2)
           |
           | void mutual_1 (void)
           |      ^~~~~~~~
           |      |
           |      (3) entry to 'mutual_1'
           |
           |   mutual_2 ();
           |   ~~~~~~~~~~~
           |   |
           |   (4) calling 'mutual_2' from 'mutual_1'
           |
           +--> 'mutual_2': events 5-6 (depth 3)
                  |
                  | void mutual_2 (void)
                  |      ^~~~~~~~
                  |      |
                  |      (5) recursive entry to 'mutual_2'; previously entered at (1)
                  |      (6) apparently infinite chain of mutually-recursive function calls, consuming 2 stack frames per recursion
                  |
   { dg-end-multiline-output "" } */


/* { dg-begin-multiline-output "" }
   mutual_1 ();
   ^~~~~~~~~~~
  'mutual_1': events 1-2 (depth 1)
    |
    | void mutual_1 (void)
    |      ^~~~~~~~
    |      |
    |      (1) initial entry to 'mutual_1'
    |
    |   mutual_2 ();
    |   ~~~~~~~~~~~
    |   |
    |   (2) calling 'mutual_2' from 'mutual_1'
    |
    +--> 'mutual_2': events 3-4 (depth 2)
           |
           | void mutual_2 (void)
           |      ^~~~~~~~
           |      |
           |      (3) entry to 'mutual_2'
           |
           |   mutual_1 ();
           |   ~~~~~~~~~~~
           |   |
           |   (4) calling 'mutual_1' from 'mutual_2'
           |
           +--> 'mutual_1': events 5-6 (depth 3)
                  |
                  | void mutual_1 (void)
                  |      ^~~~~~~~
                  |      |
                  |      (5) recursive entry to 'mutual_1'; previously entered at (1)
                  |      (6) apparently infinite chain of mutually-recursive function calls, consuming 2 stack frames per recursion
                  |
   { dg-end-multiline-output "" } */