]>
git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gcc.dg/plugin/diagnostic-path-format-default.c
1 /* { dg-do compile } */
2 /* { dg-options "-fdiagnostics-show-caret" } */
6 void *wrapped_malloc (size_t size
)
11 void wrapped_free (void *ptr
)
13 free (ptr
); /* { dg-warning "double-free of 'ptr' \\\[CWE-415\\]" } */
14 /* { dg-begin-multiline-output "" }
23 | boxed_int *obj = make_boxed_int (i);
26 | (2) calling 'make_boxed_int'
28 +--> 'make_boxed_int': events 3-4
33 | (3) entering 'make_boxed_int'
34 | boxed_int *result = (boxed_int *)wrapped_malloc (sizeof (boxed_int));
35 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
37 | (4) calling 'wrapped_malloc'
39 +--> 'wrapped_malloc': events 5-6
44 | (5) entering 'wrapped_malloc'
45 | return malloc (size);
48 | (6) calling 'malloc'
54 | free_boxed_int (obj);
55 | ^~~~~~~~~~~~~~~~~~~~
57 | (7) calling 'free_boxed_int'
59 +--> 'free_boxed_int': events 8-9
64 | (8) entering 'free_boxed_int'
68 | (9) calling 'wrapped_free'
70 +--> 'wrapped_free': events 10-11
75 | (10) entering 'wrapped_free'
85 | free_boxed_int (obj);
86 | ^~~~~~~~~~~~~~~~~~~~
88 | (12) calling 'free_boxed_int'
90 +--> 'free_boxed_int': events 13-14
95 | (13) entering 'free_boxed_int'
99 | (14) calling 'wrapped_free'
101 +--> 'wrapped_free': events 15-16
106 | (15) entering 'wrapped_free'
110 | (16) calling 'free'
112 { dg-end-multiline-output "" } */
115 typedef struct boxed_int
121 make_boxed_int (int i
)
123 boxed_int
*result
= (boxed_int
*)wrapped_malloc (sizeof (boxed_int
));
129 free_boxed_int (boxed_int
*bi
)
136 boxed_int
*obj
= make_boxed_int (i
);
138 free_boxed_int (obj
);
140 free_boxed_int (obj
);