c++: Fix ICE with #embed/RAW_DATA_CST after list conversion [PR118671]
[official-gcc.git] / gcc / testsuite / gcc.dg / plugin / diagnostic-path-format-inline-events-3.c
blob386cac91c41575fa708538fce8de6d5be1acf299
1 /* { dg-do compile } */
2 /* { dg-options "-fdiagnostics-path-format=inline-events -fdiagnostics-show-line-numbers -fdiagnostics-show-caret" } */
3 /* { dg-enable-nn-line-numbers "" } */
5 /* Verify the interaction of inline-events with line numbers. */
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 NN | free (ptr);
21 | ^~~~~~~~~~
22 'test': events 1-2
24 | NN | {
25 | | ^
26 | | |
27 | | (1) entering 'test'
28 | NN | boxed_int *obj = make_boxed_int (i);
29 | | ~~~~~~~~~~~~~~~~~~
30 | | |
31 | | (2) calling 'make_boxed_int'
33 +--> 'make_boxed_int': events 3-4
35 | NN | {
36 | | ^
37 | | |
38 | | (3) entering 'make_boxed_int'
39 | NN | boxed_int *result = (boxed_int *)wrapped_malloc (sizeof (boxed_int));
40 | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
41 | | |
42 | | (4) calling 'wrapped_malloc'
44 +--> 'wrapped_malloc': events 5-6
46 | NN | {
47 | | ^
48 | | |
49 | | (5) entering 'wrapped_malloc'
50 | NN | return malloc (size);
51 | | ~~~~~~~~~~~~~
52 | | |
53 | | (6) calling 'malloc'
55 <-------------+
57 'test': event 7
59 | NN | free_boxed_int (obj);
60 | | ^~~~~~~~~~~~~~~~~~~~
61 | | |
62 | | (7) calling 'free_boxed_int'
64 +--> 'free_boxed_int': events 8-9
66 | NN | {
67 | | ^
68 | | |
69 | | (8) entering 'free_boxed_int'
70 | NN | wrapped_free (bi);
71 | | ~~~~~~~~~~~~~~~~~
72 | | |
73 | | (9) calling 'wrapped_free'
75 +--> 'wrapped_free': events 10-11
77 | NN | {
78 | | ^
79 | | |
80 | | (10) entering 'wrapped_free'
81 | NN | 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 | NN | free_boxed_int (obj);
96 | | ^~~~~~~~~~~~~~~~~~~~
97 | | |
98 | | (13) calling 'free_boxed_int'
100 +--> 'free_boxed_int': events 14-15
102 | NN | {
103 | | ^
104 | | |
105 | | (14) entering 'free_boxed_int'
106 | NN | wrapped_free (bi);
107 | | ~~~~~~~~~~~~~~~~~
108 | | |
109 | | (15) calling 'wrapped_free'
111 +--> 'wrapped_free': events 16-17
113 | NN | {
114 | | ^
115 | | |
116 | | (16) entering 'wrapped_free'
117 | NN | free (ptr);
118 | | ~~~~~~~~~~
119 | | |
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);