aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/analyzer/inlining-7-multiline.c
blob: 956c6b90bb0715cba9a63b1e7d91a01ccb163218 (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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/* As per inlining-7.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" } */

static inline void
depth_6 (void *p)
{
  __builtin_free (p); /* { dg-warning "double-'free' of 'p1'" "warning" } */
}

static inline void
depth_5 (void *p5)
{
  depth_6 (p5);
}

static inline void
depth_4 (void *p4)
{
  depth_5 (p4);
}

static inline void
depth_3 (void *p3)
{
  depth_4 (p3);
  depth_4 (p3);
}

static inline void
depth_2 (void *p2)
{
  depth_3 (p2);
}

void
depth_1 (void *p1)
{
  depth_2 (p1);
}

/* We want the reconstructed call/return hierarchy to show
   that two calls happen at depth_3, without popping the stack
   back any further.  */

/* { dg-begin-multiline-output "" }
   __builtin_free (p);
   ^~~~~~~~~~~~~~~~~~
  'depth_1': events 1-2 (depth 1)
    |
    | depth_1 (void *p1)
    | ^~~~~~~
    | |
    | (1) entry to 'depth_1'
    |
    |   depth_2 (p1);
    |   ~
    |   |
    |   (2) inlined call to 'depth_2' from 'depth_1'
    |
    +--> 'depth_2': event 3 (depth 2)
           |
           |   depth_3 (p2);
           |   ^
           |   |
           |   (3) inlined call to 'depth_3' from 'depth_2'
           |
           +--> 'depth_3': event 4 (depth 3)
                  |
                  |   depth_4 (p3);
                  |   ^
                  |   |
                  |   (4) inlined call to 'depth_4' from 'depth_3'
                  |
                  +--> 'depth_4': event 5 (depth 4)
                         |
                         |   depth_5 (p4);
                         |   ^
                         |   |
                         |   (5) inlined call to 'depth_5' from 'depth_4'
                         |
                         +--> 'depth_5': event 6 (depth 5)
                                |
                                |   depth_6 (p5);
                                |   ^
                                |   |
                                |   (6) inlined call to 'depth_6' from 'depth_5'
                                |
                                +--> 'depth_6': event 7 (depth 6)
                                       |
                                       |   __builtin_free (p);
                                       |   ^~~~~~~~~~~~~~~~~~
                                       |   |
                                       |   (7) first 'free' here
                                       |
                  <--------------------+
                  |
                'depth_3': event 8 (depth 3)
                  |
                  |   depth_4 (p3);
                  |   ^
                  |   |
                  |   (8) inlined call to 'depth_4' from 'depth_3'
                  |
                  +--> 'depth_4': event 9 (depth 4)
                         |
                         |   depth_5 (p4);
                         |   ^
                         |   |
                         |   (9) inlined call to 'depth_5' from 'depth_4'
                         |
                         +--> 'depth_5': event 10 (depth 5)
                                |
                                |   depth_6 (p5);
                                |   ^
                                |   |
                                |   (10) inlined call to 'depth_6' from 'depth_5'
                                |
                                +--> 'depth_6': event 11 (depth 6)
                                       |
                                       |   __builtin_free (p);
                                       |   ^~~~~~~~~~~~~~~~~~
                                       |   |
                                       |   (11) second 'free' here; first 'free' was at (7)
                                       |
   { dg-end-multiline-output "" } */