1 /* { dg-additional-options "-fdiagnostics-show-line-numbers -fdiagnostics-path-format=inline-events -fdiagnostics-show-caret -fanalyzer-verbosity=0" } */
2 /* { dg-skip-if "requires hosted libstdc++ for stdlib free" { ! hostedlib } } */
3 /* { dg-enable-nn-line-numbers "" } */
7 void calls_free_1 (void *ptr
)
9 free (ptr
); /* { dg-warning "double-'free' of 'ptr'" } */
12 void test_1 (void *ptr
, int a
, int b
)
24 /* { dg-begin-multiline-output "" }
29 | NN | calls_free_1 (ptr);
30 | | ^~~~~~~~~~~~~~~~~~
32 | | (1) calling 'calls_free_1' from 'test_1'
34 +--> 'calls_free_1': event 2
39 | | (2) first 'free' here
45 | NN | calls_free_1 (ptr);
46 | | ^~~~~~~~~~~~~~~~~~
48 | | (3) returning to 'test_1' from 'calls_free_1'
50 | NN | calls_free_1 (ptr);
51 | | ~~~~~~~~~~~~~~~~~~
53 | | (4) passing freed pointer 'ptr' in call to 'calls_free_1' from 'test_1'
55 +--> 'calls_free_1': event 5
60 | | (5) second 'free' here; first 'free' was at (2)
62 { dg-end-multiline-output "" { target c } } */
63 /* { dg-begin-multiline-output "" }
66 'void test_1(void*, int, int)': event 1
68 | NN | calls_free_1 (ptr);
69 | | ~~~~~~~~~~~~~^~~~~
71 | | (1) calling 'calls_free_1' from 'test_1'
73 +--> 'void calls_free_1(void*)': event 2
78 | | (2) first 'free' here
82 'void test_1(void*, int, int)': events 3-4
84 | NN | calls_free_1 (ptr);
85 | | ~~~~~~~~~~~~~^~~~~
87 | | (3) returning to 'test_1' from 'calls_free_1'
89 | NN | calls_free_1 (ptr);
90 | | ~~~~~~~~~~~~~~~~~~
92 | | (4) passing freed pointer 'ptr' in call to 'calls_free_1' from 'test_1'
94 +--> 'void calls_free_1(void*)': event 5
99 | | (5) second 'free' here; first 'free' was at (2)
101 { dg-end-multiline-output "" { target c++ } } */
103 void calls_free_2 (void *ptr
)
105 free (ptr
); /* { dg-warning "double-'free' of 'ptr'" } */
108 void test_2 (void *ptr
, int a
, int b
)
133 /* { dg-begin-multiline-output "" }
138 | NN | calls_free_2 (ptr);
139 | | ^~~~~~~~~~~~~~~~~~
141 | | (1) calling 'calls_free_2' from 'test_2'
143 +--> 'calls_free_2': event 2
148 | | (2) first 'free' here
154 | NN | calls_free_2 (ptr);
155 | | ^~~~~~~~~~~~~~~~~~
157 | | (3) returning to 'test_2' from 'calls_free_2'
159 | NN | calls_free_2 (ptr);
160 | | ~~~~~~~~~~~~~~~~~~
162 | | (4) passing freed pointer 'ptr' in call to 'calls_free_2' from 'test_2'
164 +--> 'calls_free_2': event 5
169 | | (5) second 'free' here; first 'free' was at (2)
171 { dg-end-multiline-output "" { target c } } */
172 /* { dg-begin-multiline-output "" }
175 'void test_2(void*, int, int)': event 1
177 | NN | calls_free_2 (ptr);
178 | | ~~~~~~~~~~~~~^~~~~
180 | | (1) calling 'calls_free_2' from 'test_2'
182 +--> 'void calls_free_2(void*)': event 2
187 | | (2) first 'free' here
191 'void test_2(void*, int, int)': events 3-4
193 | NN | calls_free_2 (ptr);
194 | | ~~~~~~~~~~~~~^~~~~
196 | | (3) returning to 'test_2' from 'calls_free_2'
198 | NN | calls_free_2 (ptr);
199 | | ~~~~~~~~~~~~~~~~~~
201 | | (4) passing freed pointer 'ptr' in call to 'calls_free_2' from 'test_2'
203 +--> 'void calls_free_2(void*)': event 5
208 | | (5) second 'free' here; first 'free' was at (2)
210 { dg-end-multiline-output "" { target c++ } } */
214 /* The call/return to this function shouldn't appear in the path. */
216 void called_by_test_3 (void)
220 void test_3 (void *ptr
)
224 free (ptr
); /* { dg-warning "double-'free' of 'ptr'" } */
227 /* { dg-begin-multiline-output "" }
234 | (1) first 'free' here
235 NN | called_by_test_3 ();
239 | (2) second 'free' here; first 'free' was at (1)
240 { dg-end-multiline-output "" { target c } } */
241 /* { dg-begin-multiline-output "" }
244 'void test_3(void*)': events 1-2
248 | (1) first 'free' here
249 NN | called_by_test_3 ();
253 | (2) second 'free' here; first 'free' was at (1)
254 { dg-end-multiline-output "" { target c++ } } */