1 /* { dg-do compile } */
2 /* { dg-options "-fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */
4 /* Verify that 'inline-events' copes gracefully with events with an
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 "" }
28 | boxed_int *obj = make_boxed_int (i);
31 | (2) calling 'make_boxed_int'
33 +--> 'make_boxed_int': events 3-4
38 | (3) entering 'make_boxed_int'
39 | 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 | return malloc (size);
53 | (6) calling 'malloc'
59 | free_boxed_int (obj);
60 | ^~~~~~~~~~~~~~~~~~~~
62 | (7) calling 'free_boxed_int'
64 +--> 'free_boxed_int': events 8-9
69 | (8) entering 'free_boxed_int'
73 | (9) calling 'wrapped_free'
75 +--> 'wrapped_free': events 10-11
80 | (10) entering 'wrapped_free'
91 | (12): calling 'missing_location'
95 | free_boxed_int (obj);
96 | ^~~~~~~~~~~~~~~~~~~~
98 | (13) calling 'free_boxed_int'
100 +--> 'free_boxed_int': events 14-15
105 | (14) entering 'free_boxed_int'
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
);