1 /* { dg-do compile } */
2 /* { dg-options "-fdiagnostics-path-format=inline-events -fdiagnostics-show-line-numbers -fdiagnostics-show-caret" } */
3 /* { dg-enable-nn-line-numbers "" } */
5 /* Verify the interaction of inline-events with line numbers. */
9 extern void missing_location ();
11 void *wrapped_malloc (size_t size
)
16 void wrapped_free (void *ptr
)
18 free (ptr
); /* { dg-warning "double-free of 'ptr' \\\[CWE-415\\]" } */
19 /* { dg-begin-multiline-output "" }
27 | | (1) entering 'test'
28 | NN | boxed_int *obj = make_boxed_int (i);
29 | | ~~~~~~~~~~~~~~~~~~
31 | | (2) calling 'make_boxed_int'
33 +--> 'make_boxed_int': events 3-4
38 | | (3) entering 'make_boxed_int'
39 | NN | boxed_int *result = (boxed_int *)wrapped_malloc (sizeof (boxed_int));
40 | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
42 | | (4) calling 'wrapped_malloc'
44 +--> 'wrapped_malloc': events 5-6
49 | | (5) entering 'wrapped_malloc'
50 | NN | return malloc (size);
53 | | (6) calling 'malloc'
59 | NN | free_boxed_int (obj);
60 | | ^~~~~~~~~~~~~~~~~~~~
62 | | (7) calling 'free_boxed_int'
64 +--> 'free_boxed_int': events 8-9
69 | | (8) entering 'free_boxed_int'
70 | NN | wrapped_free (bi);
73 | | (9) calling 'wrapped_free'
75 +--> 'wrapped_free': events 10-11
80 | | (10) entering 'wrapped_free'
84 | | (11) calling 'free'
91 | (12): calling 'missing_location'
95 | NN | free_boxed_int (obj);
96 | | ^~~~~~~~~~~~~~~~~~~~
98 | | (13) calling 'free_boxed_int'
100 +--> 'free_boxed_int': events 14-15
105 | | (14) entering 'free_boxed_int'
106 | NN | wrapped_free (bi);
107 | | ~~~~~~~~~~~~~~~~~
109 | | (15) calling 'wrapped_free'
111 +--> 'wrapped_free': events 16-17
116 | | (16) entering 'wrapped_free'
120 | | (17) calling 'free'
122 { dg-end-multiline-output "" } */
125 typedef struct boxed_int
131 make_boxed_int (int i
)
133 boxed_int
*result
= (boxed_int
*)wrapped_malloc (sizeof (boxed_int
));
139 free_boxed_int (boxed_int
*bi
)
146 boxed_int
*obj
= make_boxed_int (i
);
148 free_boxed_int (obj
);
152 free_boxed_int (obj
);