@@ -24,6 +24,21 @@ Author: Daniel Kroening, kroening@kroening.com
2424
2525#include " linking_class.h"
2626
27+ bool casting_replace_symbolt::replace_symbol_expr (symbol_exprt &s) const
28+ {
29+ expr_mapt::const_iterator it = expr_map.find (s.get_identifier ());
30+
31+ if (it == expr_map.end ())
32+ return true ;
33+
34+ const exprt &e = it->second ;
35+
36+ typet type = s.type ();
37+ static_cast <exprt &>(s) = typecast_exprt::conditional_cast (e, type);
38+
39+ return false ;
40+ }
41+
2742std::string linkingt::expr_to_string (
2843 const namespacet &ns,
2944 const irep_idt &identifier,
@@ -864,6 +879,11 @@ bool linkingt::adjust_object_type_rec(
864879 " conflicting pointer types for variable" );
865880 #endif
866881
882+ if (info.old_symbol .is_extern && !info.new_symbol .is_extern )
883+ {
884+ info.set_to_new = true ; // store new type
885+ }
886+
867887 return false ;
868888 }
869889 else if (t1.id ()==ID_array &&
@@ -950,10 +970,10 @@ void linkingt::duplicate_object_symbol(
950970 symbolt &new_symbol)
951971{
952972 // both are variables
973+ bool set_to_new = false ;
953974
954975 if (!base_type_eq (old_symbol.type , new_symbol.type , ns))
955976 {
956- bool set_to_new=false ;
957977 bool failed=
958978 adjust_object_type (old_symbol, new_symbol, set_to_new);
959979
@@ -1033,6 +1053,14 @@ void linkingt::duplicate_object_symbol(
10331053 }
10341054 }
10351055 }
1056+ else if (
1057+ set_to_new && !old_symbol.value .is_nil () &&
1058+ !old_symbol.value .get_bool (ID_C_zero_initializer))
1059+ {
1060+ // the type has been updated, now make sure that the initialising assignment
1061+ // will have matching types
1062+ old_symbol.value .make_typecast (old_symbol.type );
1063+ }
10361064}
10371065
10381066void linkingt::duplicate_non_type_symbol (
0 commit comments