Skip to content

Commit 35a5d92

Browse files
author
Daniel Kroening
committed
fix for promotion of function arguments
1 parent 84d0e97 commit 35a5d92

File tree

4 files changed

+39
-0
lines changed

4 files changed

+39
-0
lines changed
638 Bytes
Binary file not shown.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
public class boolean2
2+
{
3+
public void entry(boolean b)
4+
{
5+
boolean result=f(b);
6+
assert result==!b;
7+
}
8+
9+
public boolean f(boolean b)
10+
{
11+
return !b;
12+
}
13+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
boolean2.class
3+
--function boolean2.entry
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring

src/java_bytecode/java_bytecode_convert.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,24 @@ codet java_bytecode_convertt::convert_instructions(
848848

849849
assert(this_arg.type().id()==ID_pointer);
850850
}
851+
852+
// do some type adjustment for the arguments,
853+
// as Java promotes arguments
854+
855+
for(unsigned i=0; i<parameters.size(); i++)
856+
{
857+
const typet &type=parameters[i].type();
858+
if(type==java_boolean_type() ||
859+
type==java_char_type() ||
860+
type==java_byte_type() ||
861+
type==java_short_type())
862+
{
863+
assert(i<call.arguments().size());
864+
call.arguments()[i].make_typecast(type);
865+
}
866+
}
867+
868+
// do some type adjustment for return values
851869

852870
const typet &return_type=code_type.return_type();
853871

0 commit comments

Comments
 (0)