aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/analyzer/inlining-4-multiline.c
blob: 0413c39af038d7b7cd440f4649d6c2eea8617df6 (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
/* As per inlining-4.c, but testing how the ASCII art version of
   the path looks.  */

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

#define NULL ((void *)0)

static inline const char*
inner (int flag)
{
  if (flag)
    return NULL;
  return "foo";
}

static inline const char*
middle (int flag)
{
  return inner (flag);
}

char
outer (int flag)
{
  return *middle (flag); /* { dg-warning "dereference of NULL" "warning" } */
}

/* { dg-begin-multiline-output "" }
   return *middle (flag);
          ^~~~~~~~~~~~~~
  'outer': events 1-2 (depth 1)
    |
    | outer (int flag)
    | ^~~~~
    | |
    | (1) entry to 'outer'
    |
    |   return *middle (flag);
    |           ~
    |           |
    |           (2) inlined call to 'middle' from 'outer'
    |
    +--> 'middle': event 3 (depth 2)
           |
           |   return inner (flag);
           |          ^
           |          |
           |          (3) inlined call to 'inner' from 'middle'
           |
           +--> 'inner': event 4 (depth 3)
                  |
                  |   if (flag)
                  |      ^
                  |      |
                  |      (4) following 'true' branch (when 'flag != 0')...
                  |
    <-------------+
    |
  'outer': event 5 (depth 1)
    |
    |cc1:
    | (5): ...to here
    |
  'outer': event 6 (depth 1)
    |
    |   return *middle (flag);
    |          ^~~~~~~~~~~~~~
    |          |
    |          (6) dereference of NULL '<unknown>'
    |
   { dg-end-multiline-output "" } */