@@ -4809,10 +4809,11 @@ void read_func_body(func_t *func)
48094809}
48104810
48114811/* if first token is type */
4812- void read_global_decl (block_t * block )
4812+ void read_global_decl (block_t * block , bool is_const )
48134813{
48144814 var_t * var = require_var (block );
48154815 var -> is_global = true;
4816+ var -> is_const_qualified = is_const ;
48164817
48174818 /* new function, or variables under parent */
48184819 read_full_var_decl (var , false, false);
@@ -4902,6 +4903,7 @@ void initialize_struct_field(var_t *nv, var_t *v, int offset)
49024903 nv -> is_func = false;
49034904 nv -> is_global = false;
49044905 nv -> is_initialized = false;
4906+ nv -> is_const_qualified = false;
49054907 nv -> array_size = 0 ;
49064908 nv -> offset = offset ;
49074909 nv -> init_val = 0 ;
@@ -4916,6 +4918,11 @@ void read_global_statement(void)
49164918{
49174919 char token [MAX_ID_LEN ];
49184920 block_t * block = GLOBAL_BLOCK ; /* global block */
4921+ bool is_const = false;
4922+
4923+ /* Handle const qualifier */
4924+ if (lex_accept (T_const ))
4925+ is_const = true;
49194926
49204927 if (lex_accept (T_struct )) {
49214928 int i = 0 , size = 0 ;
@@ -4931,6 +4938,7 @@ void read_global_statement(void)
49314938 /* one or more declarators */
49324939 var_t * var = require_typed_var (block , decl_type );
49334940 var -> is_global = true; /* Global struct variable */
4941+ var -> is_const_qualified = is_const ;
49344942 read_partial_var_decl (var , NULL );
49354943 add_insn (block , GLOBAL_FUNC -> bbs , OP_allocat , var , NULL , NULL , 0 ,
49364944 NULL );
@@ -5228,7 +5236,7 @@ void read_global_statement(void)
52285236 lex_expect (T_semicolon );
52295237 }
52305238 } else if (lex_peek (T_identifier , NULL )) {
5231- read_global_decl (block );
5239+ read_global_decl (block , is_const );
52325240 } else
52335241 error ("Syntax error in global statement" );
52345242}
0 commit comments