Debian Codegraph @

gcc/testsuite/gcc.dg/plugin/diagnostic-path-format-separate-events.c

raw
1 /* { dg-do compile } */
2 /* { dg-options "-fdiagnostics-path-format=separate-events" } */
3
4 #include <stdlib.h>
5
6 void *wrapped_malloc (size_t size)
7 {
8 return malloc (size);
9 }
10
11 void wrapped_free (void *ptr)
12 {
13 free (ptr); /* { dg-warning "double-free of 'ptr' \\\[CWE-415\\]" } */
14 }
15
16 typedef struct boxed_int
17 {
18 int i;
19 } boxed_int;
20
21 boxed_int *
22 make_boxed_int (int i)
23 {
24 boxed_int *result = (boxed_int *)wrapped_malloc (sizeof (boxed_int));
25 result->i = i;
26 return result;
27 }
28
29 void
30 free_boxed_int (boxed_int *bi)
31 {
32 wrapped_free (bi);
33 }
34
35 void test (int i)
36 { /* { dg-message "\\(1\\) entering 'test'" } */
37 boxed_int *obj = make_boxed_int (i); /* { dg-message "\\(2\\) calling 'make_boxed_int'" } */
38 /* etc */
39
40 free_boxed_int (obj);
41
42 free_boxed_int (obj);
43 }
44