15
15
16
16
#include < util/c_types.h>
17
17
#include < util/config.h>
18
+ #include < util/invariant.h>
18
19
#include < util/simplify_expr.h>
19
20
#include < util/arith_tools.h>
20
21
#include < util/std_types.h>
@@ -551,9 +552,15 @@ void c_typecheck_baset::typecheck_array_type(array_typet &type)
551
552
{
552
553
// not a constant and not infinity
553
554
554
- assert (!current_symbol_id .empty ());
555
+ PRECONDITION (!current_symbol. name .empty ());
555
556
556
- const symbolt &base_symbol=lookup (current_symbol_id);
557
+ if (current_symbol.is_static_lifetime )
558
+ {
559
+ error ().source_location =current_symbol.location ;
560
+ error () << " array size of static symbol `"
561
+ << current_symbol.base_name << " ' is not constant" << eom;
562
+ throw 0 ;
563
+ }
557
564
558
565
// Need to pull out! We insert new symbol.
559
566
source_locationt source_location=size.find_source_location ();
@@ -564,7 +571,7 @@ void c_typecheck_baset::typecheck_array_type(array_typet &type)
564
571
do
565
572
{
566
573
suffix=" $array_size" +std::to_string (count);
567
- temp_identifier=id2string (base_symbol .name )+suffix;
574
+ temp_identifier=id2string (current_symbol .name )+suffix;
568
575
count++;
569
576
}
570
577
while (symbol_table.symbols .find (temp_identifier)!=
@@ -573,13 +580,13 @@ void c_typecheck_baset::typecheck_array_type(array_typet &type)
573
580
// add the symbol to symbol table
574
581
auxiliary_symbolt new_symbol;
575
582
new_symbol.name =temp_identifier;
576
- new_symbol.pretty_name =id2string (base_symbol .pretty_name )+suffix;
577
- new_symbol.base_name =id2string (base_symbol .base_name )+suffix;
583
+ new_symbol.pretty_name =id2string (current_symbol .pretty_name )+suffix;
584
+ new_symbol.base_name =id2string (current_symbol .base_name )+suffix;
578
585
new_symbol.type =size.type ();
579
586
new_symbol.type .set (ID_C_constant, true );
580
587
new_symbol.is_type =false ;
581
588
new_symbol.is_static_lifetime =false ;
582
- new_symbol.value . make_nil () ;
589
+ new_symbol.value =size ;
583
590
new_symbol.location =source_location;
584
591
585
592
symbol_table.add (new_symbol);
0 commit comments