aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common/analyzer/infinite-recursion-multiline-1.c
blob: 21f38946678eebe7d79dac59498f8c1dd5c0ec4a (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
/* 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 foo (int flag)
{
  if (flag)
    foo (flag); /* { dg-warning "infinite recursion" } */
}

/* { dg-begin-multiline-output "" }
     foo (flag);
     ^~~~~~~~~~
  'foo': events 1-4 (depth 1)
    |
    | void foo (int flag)
    |      ^~~
    |      |
    |      (1) initial entry to 'foo'
    |
    |   if (flag)
    |      ~
    |      |
    |      (2) following 'true' branch (when 'flag != 0')...
    |     foo (flag);
    |     ~~~~~~~~~~
    |     |
    |     (3) ...to here
    |     (4) calling 'foo' from 'foo'
    |
    +--> 'foo': events 5-6 (depth 2)
           |
           | void foo (int flag)
           |      ^~~
           |      |
           |      (5) recursive entry to 'foo'; previously entered at (1)
           |      (6) apparently infinite recursion
           |
   { dg-end-multiline-output "" { target c } } */
/* { dg-begin-multiline-output "" }
     foo (flag);
     ~~~~^~~~~~
  'void foo(int)': events 1-4 (depth 1)
    |
    | void foo (int flag)
    |      ^~~
    |      |
    |      (1) initial entry to 'foo'
    |
    |   if (flag)
    |   ~~  
    |   |
    |   (2) following 'true' branch (when 'flag != 0')...
    |     foo (flag);
    |     ~~~~~~~~~~
    |         |
    |         (3) ...to here
    |         (4) calling 'foo' from 'foo'
    |
    +--> 'void foo(int)': events 5-6 (depth 2)
           |
           | void foo (int flag)
           |      ^~~
           |      |
           |      (5) recursive entry to 'foo'; previously entered at (1)
           |      (6) apparently infinite recursion
           |
   { dg-end-multiline-output "" { target c++ } } */