Debian Codegraph @

gcc/testsuite/gcc.dg/plugin/diagnostic-path-format-plain.c

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