@@ -126,25 +126,30 @@ std::string linkingt::type_to_string_verbose(
126
126
return type_to_string (symbol.name , type);
127
127
}
128
128
129
- void linkingt::detailed_conflict_report_rec (
129
+ bool linkingt::detailed_conflict_report_rec (
130
130
const symbolt &old_symbol,
131
131
const symbolt &new_symbol,
132
132
const typet &type1,
133
133
const typet &type2,
134
134
unsigned depth,
135
135
exprt &conflict_path)
136
136
{
137
- #ifdef DEBUG
137
+ bool conclusive = false ;
138
+
139
+ #ifdef DEBUG
138
140
debug () << " <BEGIN DEPTH " << depth << " >" << eom;
139
- #endif
141
+ #endif
140
142
141
143
std::string msg;
142
144
143
145
const typet &t1=follow_tags_symbols (ns, type1);
144
146
const typet &t2=follow_tags_symbols (ns, type2);
145
147
146
148
if (t1.id ()!=t2.id ())
149
+ {
147
150
msg=" type classes differ" ;
151
+ conclusive = true ;
152
+ }
148
153
else if (t1.id ()==ID_pointer ||
149
154
t1.id ()==ID_array)
150
155
{
@@ -155,7 +160,7 @@ void linkingt::detailed_conflict_report_rec(
155
160
if (conflict_path.type ().id () == ID_pointer)
156
161
conflict_path = dereference_exprt (conflict_path);
157
162
158
- detailed_conflict_report_rec (
163
+ conclusive = detailed_conflict_report_rec (
159
164
old_symbol,
160
165
new_symbol,
161
166
to_type_with_subtype (t1).subtype (),
@@ -184,6 +189,7 @@ void linkingt::detailed_conflict_report_rec(
184
189
msg=" number of members is different (" ;
185
190
msg+=std::to_string (components1.size ())+' /' ;
186
191
msg+=std::to_string (components2.size ())+' )' ;
192
+ conclusive = true ;
187
193
}
188
194
else
189
195
{
@@ -197,7 +203,7 @@ void linkingt::detailed_conflict_report_rec(
197
203
msg=" names of member " +std::to_string (i)+" differ (" ;
198
204
msg+=id2string (components1[i].get_name ())+' /' ;
199
205
msg+=id2string (components2[i].get_name ())+' )' ;
200
- break ;
206
+ conclusive = true ;
201
207
}
202
208
else if (subtype1 != subtype2)
203
209
{
@@ -210,6 +216,7 @@ void linkingt::detailed_conflict_report_rec(
210
216
e.id ()==ID_index)
211
217
{
212
218
parent_types.insert (e.type ());
219
+ parent_types.insert (follow_tags_symbols (ns, e.type ()));
213
220
if (e.id () == ID_dereference)
214
221
e = to_dereference_expr (e).pointer ();
215
222
else if (e.id () == ID_member)
@@ -220,44 +227,32 @@ void linkingt::detailed_conflict_report_rec(
220
227
UNREACHABLE;
221
228
}
222
229
223
- conflict_path=conflict_path_before;
224
- conflict_path.type ()=t1;
225
- conflict_path=
226
- member_exprt (conflict_path, components1[i]);
227
-
228
- if (depth>0 &&
229
- parent_types.find (t1)==parent_types.end ())
230
- detailed_conflict_report_rec (
231
- old_symbol,
232
- new_symbol,
233
- subtype1,
234
- subtype2,
235
- depth-1 ,
236
- conflict_path);
237
- else
230
+ if (parent_types.find (subtype1) == parent_types.end ())
238
231
{
239
- msg=" type of member " +
240
- id2string (components1[i].get_name ())+
241
- " differs" ;
242
- if (depth>0 )
232
+ conflict_path = conflict_path_before;
233
+ conflict_path.type () = t1;
234
+ conflict_path = member_exprt (conflict_path, components1[i]);
235
+
236
+ if (depth > 0 )
243
237
{
244
- std::string msg_bak;
245
- msg_bak.swap (msg);
246
- symbol_exprt c = symbol_exprt::typeless (ID_C_this);
247
- detailed_conflict_report_rec (
238
+ conclusive = detailed_conflict_report_rec (
248
239
old_symbol,
249
240
new_symbol,
250
241
subtype1,
251
242
subtype2,
252
- depth-1 ,
253
- c);
254
- msg.swap (msg_bak);
243
+ depth - 1 ,
244
+ conflict_path);
255
245
}
256
246
}
257
-
258
- if (parent_types.find (t1)==parent_types.end ())
259
- break ;
247
+ else
248
+ {
249
+ msg = " type of member " + id2string (components1[i].get_name ()) +
250
+ " differs (recursive)" ;
251
+ }
260
252
}
253
+
254
+ if (conclusive)
255
+ break ;
261
256
}
262
257
}
263
258
}
@@ -280,12 +275,14 @@ void linkingt::detailed_conflict_report_rec(
280
275
msg +=
281
276
type_to_string (new_symbol.name , to_c_enum_type (t2).underlying_type ()) +
282
277
' )' ;
278
+ conclusive = true ;
283
279
}
284
280
else if (members1.size ()!=members2.size ())
285
281
{
286
282
msg=" number of enum members is different (" ;
287
283
msg+=std::to_string (members1.size ())+' /' ;
288
284
msg+=std::to_string (members2.size ())+' )' ;
285
+ conclusive = true ;
289
286
}
290
287
else
291
288
{
@@ -296,15 +293,18 @@ void linkingt::detailed_conflict_report_rec(
296
293
msg=" names of member " +std::to_string (i)+" differ (" ;
297
294
msg+=id2string (members1[i].get_base_name ())+' /' ;
298
295
msg+=id2string (members2[i].get_base_name ())+' )' ;
299
- break ;
296
+ conclusive = true ;
300
297
}
301
298
else if (members1[i].get_value ()!=members2[i].get_value ())
302
299
{
303
300
msg=" values of member " +std::to_string (i)+" differ (" ;
304
301
msg+=id2string (members1[i].get_value ())+' /' ;
305
302
msg+=id2string (members2[i].get_value ())+' )' ;
306
- break ;
303
+ conclusive = true ;
307
304
}
305
+
306
+ if (conclusive)
307
+ break ;
308
308
}
309
309
}
310
310
@@ -328,21 +328,25 @@ void linkingt::detailed_conflict_report_rec(
328
328
msg=" parameter counts differ (" ;
329
329
msg+=std::to_string (parameters1.size ())+' /' ;
330
330
msg+=std::to_string (parameters2.size ())+' )' ;
331
+ conclusive = true ;
331
332
}
332
333
else if (return_type1 != return_type2)
333
334
{
335
+ conflict_path.type () = array_typet{void_type (), nil_exprt{}};
334
336
conflict_path=
335
337
index_exprt (conflict_path,
336
338
constant_exprt (std::to_string (-1 ), integer_typet ()));
337
339
338
340
if (depth>0 )
339
- detailed_conflict_report_rec (
341
+ {
342
+ conclusive = detailed_conflict_report_rec (
340
343
old_symbol,
341
344
new_symbol,
342
345
return_type1,
343
346
return_type2,
344
- depth- 1 ,
347
+ depth - 1 ,
345
348
conflict_path);
349
+ }
346
350
else
347
351
msg=" return types differ" ;
348
352
}
@@ -355,30 +359,37 @@ void linkingt::detailed_conflict_report_rec(
355
359
356
360
if (subtype1 != subtype2)
357
361
{
362
+ conflict_path.type () = array_typet{void_type (), nil_exprt{}};
358
363
conflict_path=
359
364
index_exprt (conflict_path,
360
365
constant_exprt (std::to_string (i), integer_typet ()));
361
366
362
367
if (depth>0 )
363
- detailed_conflict_report_rec (
368
+ {
369
+ conclusive = detailed_conflict_report_rec (
364
370
old_symbol,
365
371
new_symbol,
366
372
subtype1,
367
373
subtype2,
368
- depth- 1 ,
374
+ depth - 1 ,
369
375
conflict_path);
376
+ }
370
377
else
371
378
msg=" parameter types differ" ;
379
+ }
372
380
381
+ if (conclusive)
373
382
break ;
374
- }
375
383
}
376
384
}
377
385
}
378
386
else
387
+ {
379
388
msg=" conflict on POD" ;
389
+ conclusive = true ;
390
+ }
380
391
381
- if (!msg.empty ())
392
+ if (conclusive && !msg.empty ())
382
393
{
383
394
error () << ' \n ' ;
384
395
error () << " reason for conflict at "
@@ -392,6 +403,8 @@ void linkingt::detailed_conflict_report_rec(
392
403
#ifdef DEBUG
393
404
debug () << " <END DEPTH " << depth << " >" << eom;
394
405
#endif
406
+
407
+ return conclusive;
395
408
}
396
409
397
410
void linkingt::link_error (
@@ -685,8 +698,16 @@ void linkingt::duplicate_code_symbol(
685
698
old_symbol.value .is_nil ()!=new_symbol.value .is_nil ())
686
699
{
687
700
if (warn_msg.empty ())
701
+ {
688
702
warn_msg=" pointer parameter types differ between "
689
703
" declaration and definition" ;
704
+ detailed_conflict_report (
705
+ old_symbol,
706
+ new_symbol,
707
+ conflicts.front ().first ,
708
+ conflicts.front ().second );
709
+ }
710
+
690
711
replace=new_symbol.value .is_not_nil ();
691
712
}
692
713
// transparent union with (or entirely without) implementation is
0 commit comments