@@ -452,15 +452,23 @@ void linkingt::duplicate_code_symbol(
452
452
const code_typet &old_t =to_code_type (old_symbol.type );
453
453
const code_typet &new_t =to_code_type (new_symbol.type );
454
454
455
- // if one of them was an implicit declaration, just issue a warning
455
+ // if one of them was an implicit declaration then only conflicts on the
456
+ // return type are an error as we would end up with assignments with
457
+ // mismatching types; as we currently do not patch these by inserting type
458
+ // casts we need to fail hard
456
459
if (!old_symbol.location .get_function ().empty () &&
457
460
old_symbol.value .is_nil ())
458
461
{
459
- // issue a warning and overwrite
460
- link_warning (
461
- old_symbol,
462
- new_symbol,
463
- " implicit function declaration" );
462
+ if (base_type_eq (old_t .return_type (), new_t .return_type (), ns))
463
+ link_warning (
464
+ old_symbol,
465
+ new_symbol,
466
+ " implicit function declaration" );
467
+ else
468
+ link_error (
469
+ old_symbol,
470
+ new_symbol,
471
+ " implicit function declaration" );
464
472
465
473
old_symbol.type =new_symbol.type ;
466
474
old_symbol.location =new_symbol.location ;
@@ -469,11 +477,16 @@ void linkingt::duplicate_code_symbol(
469
477
else if (!new_symbol.location .get_function ().empty () &&
470
478
new_symbol.value .is_nil ())
471
479
{
472
- // issue a warning
473
- link_warning (
474
- old_symbol,
475
- new_symbol,
476
- " ignoring conflicting implicit function declaration" );
480
+ if (base_type_eq (old_t .return_type (), new_t .return_type (), ns))
481
+ link_warning (
482
+ old_symbol,
483
+ new_symbol,
484
+ " ignoring conflicting implicit function declaration" );
485
+ else
486
+ link_error (
487
+ old_symbol,
488
+ new_symbol,
489
+ " implicit function declaration" );
477
490
}
478
491
// handle (incomplete) function prototypes
479
492
else if (base_type_eq (old_t .return_type (), new_t .return_type (), ns) &&
0 commit comments