|
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/rational.h>
|
24 | 25 | #include <util/rational_tools.h>
|
25 | 26 | #include <util/simplify_expr.h>
|
@@ -1306,12 +1307,24 @@ void goto_convertt::do_function_call_symbol(
|
1306 | 1307 | goto_programt::make_assignment(lhs, rhs, function.source_location()));
|
1307 | 1308 | }
|
1308 | 1309 |
|
1309 |
| - code_assignt assign{ |
1310 |
| - list_arg, plus_exprt{list_arg, from_integer(1, pointer_diff_type())}}; |
1311 |
| - assign.rhs().set( |
1312 |
| - ID_C_va_arg_type, to_code_type(function.type()).return_type()); |
| 1310 | + exprt rhs; |
| 1311 | + if(list_arg.type() == pointer_type(pointer_type(empty_typet{}))) |
| 1312 | + rhs = plus_exprt{list_arg, from_integer(1, pointer_diff_type())}; |
| 1313 | + else |
| 1314 | + { |
| 1315 | + // handle unexpected va_list types by just enforcing pointer increments by |
| 1316 | + // size-of-void* |
| 1317 | + rhs = typecast_exprt{ |
| 1318 | + plus_exprt{ |
| 1319 | + typecast_exprt{list_arg, pointer_type(char_type())}, |
| 1320 | + from_integer( |
| 1321 | + *pointer_offset_size(pointer_type(empty_typet{}), ns), |
| 1322 | + pointer_diff_type())}, |
| 1323 | + list_arg.type()}; |
| 1324 | + } |
| 1325 | + rhs.set(ID_C_va_arg_type, to_code_type(function.type()).return_type()); |
1313 | 1326 | dest.add(goto_programt::make_assignment(
|
1314 |
| - std::move(assign), function.source_location())); |
| 1327 | + list_arg, std::move(rhs), function.source_location())); |
1315 | 1328 | }
|
1316 | 1329 | else if(identifier == "__builtin_va_copy")
|
1317 | 1330 | {
|
|
0 commit comments