1 /* { dg-additional-options "-fdiagnostics-show-line-numbers -fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */
2 /* { dg-enable-nn-line-numbers "" } */
6 extern int some_condition ();
7 extern void do_stuff (int);
10 may_call_free (void *victim
)
12 if (some_condition ())
15 free (victim
); /* { dg-warning "double-'free' of 'victim'" } */
31 /* { dg-begin-multiline-output "" }
36 | NN | void test (void *ptr)
39 | | (1) entry to 'test'
41 | NN | may_call_free (ptr);
42 | | ~~~~~~~~~~~~~~~~~~~
44 | | (2) calling 'may_call_free' from 'test'
46 +--> 'may_call_free': events 3-6
48 | NN | may_call_free (void *victim)
51 | | (3) entry to 'may_call_free'
53 | NN | if (some_condition ())
56 | | (4) following 'false' branch...
62 | | (6) first 'free' here
68 | NN | may_call_free (ptr);
69 | | ^~~~~~~~~~~~~~~~~~~
71 | | (7) returning to 'test' from 'may_call_free'
73 | NN | may_call_free (ptr);
74 | | ~~~~~~~~~~~~~~~~~~~
76 | | (8) passing freed pointer 'ptr' in call to 'may_call_free' from 'test'
78 +--> 'may_call_free': events 9-12
80 | NN | may_call_free (void *victim)
83 | | (9) entry to 'may_call_free'
85 | NN | if (some_condition ())
88 | | (10) following 'false' branch...
94 | | (12) second 'free' here; first 'free' was at (6)
96 { dg-end-multiline-output "" { target c } } */
97 /* { dg-begin-multiline-output "" }
100 'void test(void*)': events 1-2
102 | NN | void test (void *ptr)
105 | | (1) entry to 'test'
107 | NN | may_call_free (ptr);
108 | | ~~~~~~~~~~~~~~~~~~~
110 | | (2) calling 'may_call_free' from 'test'
112 +--> 'void may_call_free(void*)': events 3-6
114 | NN | may_call_free (void *victim)
117 | | (3) entry to 'may_call_free'
119 | NN | if (some_condition ())
122 | | (4) following 'false' branch...
124 | NN | free (victim);
128 | | (6) first 'free' here
132 'void test(void*)': events 7-8
134 | NN | may_call_free (ptr);
135 | | ~~~~~~~~~~~~~~^~~~~
137 | | (7) returning to 'test' from 'may_call_free'
139 | NN | may_call_free (ptr);
140 | | ~~~~~~~~~~~~~~~~~~~
142 | | (8) passing freed pointer 'ptr' in call to 'may_call_free' from 'test'
144 +--> 'void may_call_free(void*)': events 9-12
146 | NN | may_call_free (void *victim)
149 | | (9) entry to 'may_call_free'
151 | NN | if (some_condition ())
154 | | (10) following 'false' branch...
156 | NN | free (victim);
160 | | (12) second 'free' here; first 'free' was at (6)
162 { dg-end-multiline-output "" { target c++ } } */