aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/analyzer/infinite-recursion-multiline-1.c
blob: e236dd48712dbbf61949cccaa4c82c32fb5ed8d8 (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
/* 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 "" } */