|
24 | 24 |
|
25 | 25 | #include "linking_class.h" |
26 | 26 |
|
| 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 | + |
27 | 42 | std::string linkingt::expr_to_string( |
28 | 43 | const namespacet &ns, |
29 | 44 | const irep_idt &identifier, |
@@ -875,6 +890,11 @@ bool linkingt::adjust_object_type_rec( |
875 | 890 | "conflicting pointer types for variable"); |
876 | 891 | #endif |
877 | 892 |
|
| 893 | + if(info.old_symbol.is_extern && !info.new_symbol.is_extern) |
| 894 | + { |
| 895 | + info.set_to_new = true; // store new type |
| 896 | + } |
| 897 | + |
878 | 898 | return false; |
879 | 899 | } |
880 | 900 | else if(t1.id()==ID_array && |
@@ -961,10 +981,10 @@ void linkingt::duplicate_object_symbol( |
961 | 981 | symbolt &new_symbol) |
962 | 982 | { |
963 | 983 | // both are variables |
| 984 | + bool set_to_new = false; |
964 | 985 |
|
965 | 986 | if(!base_type_eq(old_symbol.type, new_symbol.type, ns)) |
966 | 987 | { |
967 | | - bool set_to_new=false; |
968 | 988 | bool failed= |
969 | 989 | adjust_object_type(old_symbol, new_symbol, set_to_new); |
970 | 990 |
|
@@ -1043,6 +1063,14 @@ void linkingt::duplicate_object_symbol( |
1043 | 1063 | } |
1044 | 1064 | } |
1045 | 1065 | } |
| 1066 | + else if( |
| 1067 | + set_to_new && !old_symbol.value.is_nil() && |
| 1068 | + !old_symbol.value.get_bool(ID_C_zero_initializer)) |
| 1069 | + { |
| 1070 | + // the type has been updated, now make sure that the initialising assignment |
| 1071 | + // will have matching types |
| 1072 | + old_symbol.value.make_typecast(old_symbol.type); |
| 1073 | + } |
1046 | 1074 | } |
1047 | 1075 |
|
1048 | 1076 | void linkingt::duplicate_non_type_symbol( |
|
0 commit comments