|
16 | 16 | #include <util/arith_tools.h>
|
17 | 17 | #include <util/c_types.h>
|
18 | 18 | #include <util/config.h>
|
19 |
| -#include <util/fresh_symbol.h> |
20 | 19 | #include <util/mathematical_types.h>
|
21 | 20 | #include <util/pointer_offset_size.h>
|
22 | 21 | #include <util/simplify_expr.h>
|
@@ -609,25 +608,44 @@ void c_typecheck_baset::typecheck_array_type(array_typet &type)
|
609 | 608 | throw 0;
|
610 | 609 | }
|
611 | 610 |
|
612 |
| - symbolt &new_symbol = get_fresh_aux_symbol( |
613 |
| - size_type(), |
614 |
| - id2string(current_symbol.name) + "$array_size", |
615 |
| - id2string(current_symbol.base_name) + "$array_size", |
616 |
| - size_source_location, |
617 |
| - mode, |
618 |
| - symbol_table); |
| 611 | + // Need to pull out! We insert new symbol. |
| 612 | + unsigned count=0; |
| 613 | + irep_idt temp_identifier; |
| 614 | + std::string suffix; |
| 615 | + |
| 616 | + do |
| 617 | + { |
| 618 | + suffix="$array_size"+std::to_string(count); |
| 619 | + temp_identifier=id2string(current_symbol.name)+suffix; |
| 620 | + count++; |
| 621 | + } |
| 622 | + while(symbol_table.symbols.find(temp_identifier)!= |
| 623 | + symbol_table.symbols.end()); |
| 624 | + |
| 625 | + // add the symbol to symbol table |
| 626 | + auxiliary_symbolt new_symbol; |
| 627 | + new_symbol.name=temp_identifier; |
| 628 | + new_symbol.pretty_name=id2string(current_symbol.pretty_name)+suffix; |
| 629 | + new_symbol.base_name=id2string(current_symbol.base_name)+suffix; |
| 630 | + new_symbol.type=size.type(); |
619 | 631 | new_symbol.type.set(ID_C_constant, true);
|
620 |
| - new_symbol.value = typecast_exprt::conditional_cast(size, size_type()); |
| 632 | + new_symbol.value=size; |
| 633 | + new_symbol.location = size_source_location; |
| 634 | + new_symbol.mode = mode; |
| 635 | + |
| 636 | + symbol_table.add(new_symbol); |
621 | 637 |
|
622 | 638 | // produce the code that declares and initializes the symbol
|
623 |
| - symbol_exprt symbol_expr = new_symbol.symbol_expr(); |
| 639 | + symbol_exprt symbol_expr; |
| 640 | + symbol_expr.set_identifier(temp_identifier); |
| 641 | + symbol_expr.type()=new_symbol.type; |
624 | 642 |
|
625 | 643 | code_declt declaration(symbol_expr);
|
626 | 644 | declaration.add_source_location() = size_source_location;
|
627 | 645 |
|
628 | 646 | code_assignt assignment;
|
629 | 647 | assignment.lhs()=symbol_expr;
|
630 |
| - assignment.rhs() = new_symbol.value; |
| 648 | + assignment.rhs()=size; |
631 | 649 | assignment.add_source_location() = size_source_location;
|
632 | 650 |
|
633 | 651 | // store the code
|
|
0 commit comments