|
20 | 20 | #include <util/mathematical_expr.h>
|
21 | 21 | #include <util/mathematical_types.h>
|
22 | 22 | #include <util/pointer_expr.h>
|
| 23 | +#include <util/pointer_offset_size.h> |
23 | 24 | #include <util/prefix.h>
|
24 | 25 | #include <util/rational.h>
|
25 | 26 | #include <util/rational_tools.h>
|
@@ -1299,12 +1300,24 @@ void goto_convertt::do_function_call_symbol(
|
1299 | 1300 | goto_programt::make_assignment(lhs, rhs, function.source_location()));
|
1300 | 1301 | }
|
1301 | 1302 |
|
1302 |
| - code_assignt assign{ |
1303 |
| - list_arg, plus_exprt{list_arg, from_integer(1, pointer_diff_type())}}; |
1304 |
| - assign.rhs().set( |
1305 |
| - ID_C_va_arg_type, to_code_type(function.type()).return_type()); |
| 1303 | + exprt rhs; |
| 1304 | + if(list_arg.type() == pointer_type(pointer_type(empty_typet{}))) |
| 1305 | + rhs = plus_exprt{list_arg, from_integer(1, pointer_diff_type())}; |
| 1306 | + else |
| 1307 | + { |
| 1308 | + // handle unexpected va_list types by just enforcing pointer increments by |
| 1309 | + // size-of-void* |
| 1310 | + rhs = typecast_exprt{ |
| 1311 | + plus_exprt{ |
| 1312 | + typecast_exprt{list_arg, pointer_type(char_type())}, |
| 1313 | + from_integer( |
| 1314 | + *pointer_offset_size(pointer_type(empty_typet{}), ns), |
| 1315 | + pointer_diff_type())}, |
| 1316 | + list_arg.type()}; |
| 1317 | + } |
| 1318 | + rhs.set(ID_C_va_arg_type, to_code_type(function.type()).return_type()); |
1306 | 1319 | dest.add(goto_programt::make_assignment(
|
1307 |
| - std::move(assign), function.source_location())); |
| 1320 | + list_arg, std::move(rhs), function.source_location())); |
1308 | 1321 | }
|
1309 | 1322 | else if(identifier=="__builtin_va_copy")
|
1310 | 1323 | {
|
|
0 commit comments