@@ -733,17 +733,21 @@ codet java_bytecode_convert_methodt::convert_instructions(
733
733
734
734
// do some type adjustment for the arguments,
735
735
// as Java promotes arguments
736
+ // Also cast pointers since intermediate locals
737
+ // can be void*.
736
738
737
739
for (std::size_t i=0 ; i<parameters.size (); i++)
738
740
{
739
741
const typet &type=parameters[i].type ();
740
742
if (type==java_boolean_type () ||
741
743
type==java_char_type () ||
742
744
type==java_byte_type () ||
743
- type==java_short_type ())
745
+ type==java_short_type () ||
746
+ type.id ()==ID_pointer)
744
747
{
745
748
assert (i<call.arguments ().size ());
746
- call.arguments ()[i].make_typecast (type);
749
+ if (type!=call.arguments ()[i].type ())
750
+ call.arguments ()[i].make_typecast (type);
747
751
}
748
752
}
749
753
@@ -833,12 +837,11 @@ codet java_bytecode_convert_methodt::convert_instructions(
833
837
834
838
exprt var=variable (arg0, statement[0 ], i_it->address , INST_INDEX);
835
839
836
- const bool is_array (' a' == statement[0 ]);
840
+ exprt toassign=op[0 ];
841
+ if (' a' ==statement[0 ] && toassign.type ()!=var.type ())
842
+ toassign=typecast_exprt (toassign, var.type ());
837
843
838
- if (is_array)
839
- var.type ()=op[0 ].type ();
840
-
841
- c=code_assignt (var, op[0 ]);
844
+ c=code_assignt (var, toassign);
842
845
}
843
846
else if (statement==patternt (" ?aload" ))
844
847
{
@@ -999,7 +1002,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
999
1002
irep_idt number=to_constant_expr (arg0).get_value ();
1000
1003
assert (op.size ()==1 && results.empty ());
1001
1004
code_ifthenelset code_branch;
1002
- const typecast_exprt lhs (op[0 ], pointer_typet ());
1005
+ const typecast_exprt lhs (op[0 ], pointer_typet (empty_typet () ));
1003
1006
const exprt rhs (gen_zero (lhs.type ()));
1004
1007
code_branch.cond ()=binary_relation_exprt (lhs, ID_notequal, rhs);
1005
1008
code_branch.then_case ()=code_gotot (label (number));
0 commit comments