aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common/analyzer/inlining-7-multiline.c
blob: 78fe4d4a6bf4fa1fc5965c47bc250867592cb3c0 (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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
/* 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 "" { target c } } */
/* { dg-begin-multiline-output "" }
   __builtin_free (p);
   ~~~~~~~~~~~~~~~^~~
  'void depth_1(void*)': 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'
    |
    +--> 'void depth_2(void*)': event 3 (depth 2)
           |
           |   depth_3 (p2);
           |           ^
           |           |
           |           (3) inlined call to 'depth_3' from 'depth_2'
           |
           +--> 'void depth_3(void*)': event 4 (depth 3)
                  |
                  |   depth_4 (p3);
                  |           ^
                  |           |
                  |           (4) inlined call to 'depth_4' from 'depth_3'
                  |
                  +--> 'void depth_4(void*)': event 5 (depth 4)
                         |
                         |   depth_5 (p4);
                         |           ^
                         |           |
                         |           (5) inlined call to 'depth_5' from 'depth_4'
                         |
                         +--> 'void depth_5(void*)': event 6 (depth 5)
                                |
                                |   depth_6 (p5);
                                |           ^
                                |           |
                                |           (6) inlined call to 'depth_6' from 'depth_5'
                                |
                                +--> 'void depth_6(void*)': event 7 (depth 6)
                                       |
                                       |   __builtin_free (p);
                                       |   ~~~~~~~~~~~~~~~^~~
                                       |                  |
                                       |                  (7) first 'free' here
                                       |
                  <--------------------+
                  |
                'void depth_3(void*)': event 8 (depth 3)
                  |
                  |   depth_4 (p3);
                  |           ^
                  |           |
                  |           (8) inlined call to 'depth_4' from 'depth_3'
                  |
                  +--> 'void depth_4(void*)': event 9 (depth 4)
                         |
                         |   depth_5 (p4);
                         |           ^
                         |           |
                         |           (9) inlined call to 'depth_5' from 'depth_4'
                         |
                         +--> 'void depth_5(void*)': event 10 (depth 5)
                                |
                                |   depth_6 (p5);
                                |           ^
                                |           |
                                |           (10) inlined call to 'depth_6' from 'depth_5'
                                |
                                +--> 'void depth_6(void*)': event 11 (depth 6)
                                       |
                                       |   __builtin_free (p);
                                       |   ~~~~~~~~~~~~~~~^~~
                                       |                  |
                                       |                  (11) second 'free' here; first 'free' was at (7)
                                       |
   { dg-end-multiline-output "" { target c++ } } */