|
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,
|
@@ -873,6 +888,11 @@ bool linkingt::adjust_object_type_rec(
|
873 | 888 | "conflicting pointer types for variable");
|
874 | 889 | #endif
|
875 | 890 |
|
| 891 | + if(info.old_symbol.is_extern && !info.new_symbol.is_extern) |
| 892 | + { |
| 893 | + info.set_to_new = true; // store new type |
| 894 | + } |
| 895 | + |
876 | 896 | return false;
|
877 | 897 | }
|
878 | 898 | else if(t1.id()==ID_array &&
|
@@ -959,10 +979,10 @@ void linkingt::duplicate_object_symbol(
|
959 | 979 | symbolt &new_symbol)
|
960 | 980 | {
|
961 | 981 | // both are variables
|
| 982 | + bool set_to_new = false; |
962 | 983 |
|
963 | 984 | if(!base_type_eq(old_symbol.type, new_symbol.type, ns))
|
964 | 985 | {
|
965 |
| - bool set_to_new=false; |
966 | 986 | bool failed=
|
967 | 987 | adjust_object_type(old_symbol, new_symbol, set_to_new);
|
968 | 988 |
|
@@ -1042,6 +1062,14 @@ void linkingt::duplicate_object_symbol(
|
1042 | 1062 | }
|
1043 | 1063 | }
|
1044 | 1064 | }
|
| 1065 | + else if( |
| 1066 | + set_to_new && !old_symbol.value.is_nil() && |
| 1067 | + !old_symbol.value.get_bool(ID_C_zero_initializer)) |
| 1068 | + { |
| 1069 | + // the type has been updated, now make sure that the initialising assignment |
| 1070 | + // will have matching types |
| 1071 | + old_symbol.value.make_typecast(old_symbol.type); |
| 1072 | + } |
1045 | 1073 | }
|
1046 | 1074 |
|
1047 | 1075 | void linkingt::duplicate_non_type_symbol(
|
|
0 commit comments