Debian Codegraph @

gcc/testsuite/c-c++-common/analyzer/infinite-recursion-4-limited-buggy.c

raw
1 /* { dg-additional-options "-fno-analyzer-call-summaries -Wno-analyzer-too-complex" } */
2
3 /* A two-deep mutual recursion, and failing to walk a list,
4 but with a depth limit, thus not an infinite recursion (assuming a
5 suitable depth limit). */
6
7 struct node
8 {
9 struct node *child;
10 };
11
12 void foo (struct node *f, int depth);
13
14 void bar (struct node *b, int depth)
15 {
16 foo (b, depth); /* { dg-bogus "infinite recursion" } */
17 }
18
19 void foo (struct node *f, int depth)
20 {
21 if (f->child && depth > 0)
22 /* Bug: should have recursed to f->child, not to f,
23 but we assume that the depth limit should save us. */
24 bar (f, depth - 1); /* { dg-bogus "infinite recursion" } */
25 }