libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / plugin / diagnostic-path-format-inline-events-2.c
blobc2bfabec9101216669d7e893eb444f2c9e5bfde6
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
5 unknown location. */
7 #include <stdlib.h>
9 extern void missing_location ();
11 void *wrapped_malloc (size_t size)
13 return malloc (size);
16 void wrapped_free (void *ptr)
18 free (ptr); /* { dg-warning "double-free of 'ptr' \\\[CWE-415\\]" } */
19 /* { dg-begin-multiline-output "" }
20 free (ptr);
21 ^~~~~~~~~~
22 'test': events 1-2
24 | {
25 | ^
26 | |
27 | (1) entering 'test'
28 | boxed_int *obj = make_boxed_int (i);
29 | ~~~~~~~~~~~~~~~~~~
30 | |
31 | (2) calling 'make_boxed_int'
33 +--> 'make_boxed_int': events 3-4
35 | {
36 | ^
37 | |
38 | (3) entering 'make_boxed_int'
39 | boxed_int *result = (boxed_int *)wrapped_malloc (sizeof (boxed_int));
40 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
41 | |
42 | (4) calling 'wrapped_malloc'
44 +--> 'wrapped_malloc': events 5-6
46 | {
47 | ^
48 | |
49 | (5) entering 'wrapped_malloc'
50 | return malloc (size);
51 | ~~~~~~~~~~~~~
52 | |
53 | (6) calling 'malloc'
55 <-------------+
57 'test': event 7
59 | free_boxed_int (obj);
60 | ^~~~~~~~~~~~~~~~~~~~
61 | |
62 | (7) calling 'free_boxed_int'
64 +--> 'free_boxed_int': events 8-9
66 | {
67 | ^
68 | |
69 | (8) entering 'free_boxed_int'
70 | wrapped_free (bi);
71 | ~~~~~~~~~~~~~~~~~
72 | |
73 | (9) calling 'wrapped_free'
75 +--> 'wrapped_free': events 10-11
77 | {
78 | ^
79 | |
80 | (10) entering 'wrapped_free'
81 | free (ptr);
82 | ~~~~~~~~~~
83 | |
84 | (11) calling 'free'
86 <-------------+
88 'test': event 12
90 |cc1:
91 | (12): calling 'missing_location'
93 'test': event 13
95 | free_boxed_int (obj);
96 | ^~~~~~~~~~~~~~~~~~~~
97 | |
98 | (13) calling 'free_boxed_int'
100 +--> 'free_boxed_int': events 14-15
105 | (14) entering 'free_boxed_int'
106 | wrapped_free (bi);
107 | ~~~~~~~~~~~~~~~~~
109 | (15) calling 'wrapped_free'
111 +--> 'wrapped_free': events 16-17
116 | (16) entering 'wrapped_free'
117 | free (ptr);
118 | ~~~~~~~~~~
120 | (17) calling 'free'
122 { dg-end-multiline-output "" } */
125 typedef struct boxed_int
127 int i;
128 } boxed_int;
130 boxed_int *
131 make_boxed_int (int i)
133 boxed_int *result = (boxed_int *)wrapped_malloc (sizeof (boxed_int));
134 result->i = i;
135 return result;
138 void
139 free_boxed_int (boxed_int *bi)
141 wrapped_free (bi);
144 void test (int i)
146 boxed_int *obj = make_boxed_int (i);
148 free_boxed_int (obj);
150 missing_location ();
152 free_boxed_int (obj);