|
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,
|
@@ -864,6 +879,11 @@ bool linkingt::adjust_object_type_rec(
|
864 | 879 | "conflicting pointer types for variable");
|
865 | 880 | #endif
|
866 | 881 |
|
| 882 | + if(info.old_symbol.is_extern && !info.new_symbol.is_extern) |
| 883 | + { |
| 884 | + info.set_to_new = true; // store new type |
| 885 | + } |
| 886 | + |
867 | 887 | return false;
|
868 | 888 | }
|
869 | 889 | else if(t1.id()==ID_array &&
|
@@ -950,10 +970,10 @@ void linkingt::duplicate_object_symbol(
|
950 | 970 | symbolt &new_symbol)
|
951 | 971 | {
|
952 | 972 | // both are variables
|
| 973 | + bool set_to_new = false; |
953 | 974 |
|
954 | 975 | if(!base_type_eq(old_symbol.type, new_symbol.type, ns))
|
955 | 976 | {
|
956 |
| - bool set_to_new=false; |
957 | 977 | bool failed=
|
958 | 978 | adjust_object_type(old_symbol, new_symbol, set_to_new);
|
959 | 979 |
|
@@ -1033,6 +1053,14 @@ void linkingt::duplicate_object_symbol(
|
1033 | 1053 | }
|
1034 | 1054 | }
|
1035 | 1055 | }
|
| 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 | + } |
1036 | 1064 | }
|
1037 | 1065 |
|
1038 | 1066 | void linkingt::duplicate_non_type_symbol(
|
|
0 commit comments