Skip to content

Treat all anonymous locals as void* #387

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions src/java_bytecode/java_bytecode_convert_method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -731,17 +731,21 @@ codet java_bytecode_convert_methodt::convert_instructions(

// do some type adjustment for the arguments,
// as Java promotes arguments
// Also cast pointers since intermediate locals
// can be void*.

for(std::size_t i=0; i<parameters.size(); i++)
{
const typet &type=parameters[i].type();
if(type==java_boolean_type() ||
type==java_char_type() ||
type==java_byte_type() ||
type==java_short_type())
type==java_short_type() ||
type.id()==ID_pointer)
{
assert(i<call.arguments().size());
call.arguments()[i].make_typecast(type);
if(type!=call.arguments()[i].type())
call.arguments()[i].make_typecast(type);
}
}

Expand Down Expand Up @@ -831,12 +835,11 @@ codet java_bytecode_convert_methodt::convert_instructions(

exprt var=variable(arg0, statement[0], i_it->address, INST_INDEX);

const bool is_array('a' == statement[0]);
exprt toassign=op[0];
if('a'==statement[0] && toassign.type()!=var.type())
toassign=typecast_exprt(toassign, var.type());

if(is_array)
var.type()=op[0].type();

c=code_assignt(var, op[0]);
c=code_assignt(var, toassign);
}
else if(statement==patternt("?aload"))
{
Expand Down Expand Up @@ -997,7 +1000,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
irep_idt number=to_constant_expr(arg0).get_value();
assert(op.size()==1 && results.empty());
code_ifthenelset code_branch;
const typecast_exprt lhs(op[0], pointer_typet());
const typecast_exprt lhs(op[0], pointer_typet(empty_typet()));
const exprt rhs(gen_zero(lhs.type()));
code_branch.cond()=binary_relation_exprt(lhs, ID_notequal, rhs);
code_branch.then_case()=code_gotot(label(number));
Expand Down