X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;ds=sidebyside;f=parser.c;h=417b1e23c03325ae9d18118042d8d7cc654af47b;hb=d7d33f2a6f135d3e8c948726f97bb6d9fab3e781;hp=0ef345017d2d2955a4ffab64b0a3f3d31d48534f;hpb=570b9d56ee8cc8b9e35c38da66b48766ea8cf5c6;p=cparser diff --git a/parser.c b/parser.c index 0ef3450..417b1e2 100644 --- a/parser.c +++ b/parser.c @@ -100,34 +100,34 @@ typedef struct parse_initializer_env_t { typedef entity_t* (*parsed_declaration_func) (entity_t *declaration, bool is_definition); /** The current token. */ -static token_t token; +static token_t token; /** The lookahead ring-buffer. */ -static token_t lookahead_buffer[MAX_LOOKAHEAD]; +static token_t lookahead_buffer[MAX_LOOKAHEAD]; /** Position of the next token in the lookahead buffer. */ -static int lookahead_bufpos; -static stack_entry_t *environment_stack = NULL; -static stack_entry_t *label_stack = NULL; -static scope_t *file_scope = NULL; -static scope_t *current_scope = NULL; +static int lookahead_bufpos; +static stack_entry_t *environment_stack = NULL; +static stack_entry_t *label_stack = NULL; +static scope_t *file_scope = NULL; +static scope_t *current_scope = NULL; /** Point to the current function declaration if inside a function. */ -static function_t *current_function = NULL; -static entity_t *current_init_decl = NULL; -static switch_statement_t *current_switch = NULL; -static statement_t *current_loop = NULL; -static statement_t *current_parent = NULL; -static ms_try_statement_t *current_try = NULL; -static linkage_kind_t current_linkage = LINKAGE_INVALID; -static goto_statement_t *goto_first = NULL; -static goto_statement_t *goto_last = NULL; -static label_statement_t *label_first = NULL; -static label_statement_t *label_last = NULL; +static function_t *current_function = NULL; +static entity_t *current_init_decl = NULL; +static switch_statement_t *current_switch = NULL; +static statement_t *current_loop = NULL; +static statement_t *current_parent = NULL; +static ms_try_statement_t *current_try = NULL; +static linkage_kind_t current_linkage = LINKAGE_INVALID; +static goto_statement_t *goto_first = NULL; +static goto_statement_t **goto_anchor = NULL; +static label_statement_t *label_first = NULL; +static label_statement_t **label_anchor = NULL; /** current translation unit. */ -static translation_unit_t *unit = NULL; +static translation_unit_t *unit = NULL; /** true if we are in a type property context (evaluation only for type. */ -static bool in_type_prop = false; +static bool in_type_prop = false; /** true in we are in a __extension__ context. */ -static bool in_gcc_extension = false; -static struct obstack temp_obst; +static bool in_gcc_extension = false; +static struct obstack temp_obst; #define PUSH_PARENT(stmt) \ @@ -5272,8 +5272,8 @@ static void check_labels(void) "label '%Y' used but not defined", label->base.symbol); } } - goto_first = NULL; - goto_last = NULL; + goto_first = NULL; + goto_anchor = &goto_first; if (warning.unused_label) { for (const label_statement_t *label_statement = label_first; @@ -5288,7 +5288,8 @@ static void check_labels(void) } } } - label_first = label_last = NULL; + label_first = NULL; + label_anchor = &label_first; } static void warn_unused_decl(entity_t *entity, entity_t *end, @@ -9508,12 +9509,8 @@ static statement_t *parse_label_statement(void) } /* remember the labels in a list for later checking */ - if (label_last == NULL) { - label_first = &statement->label; - } else { - label_last->next = &statement->label; - } - label_last = &statement->label; + *label_anchor = &statement->label; + label_anchor = &statement->label.next; POP_PARENT; return statement; @@ -9812,8 +9809,8 @@ static statement_t *parse_goto(void) expression_t *expression = parse_expression(); mark_vars_read(expression, NULL); - /* Argh: although documentation say the expression must be of type void *, - * gcc excepts anything that can be casted into void * without error */ + /* Argh: although documentation says the expression must be of type void*, + * gcc accepts anything that can be casted into void* without error */ type_t *type = expression->base.type; if (type != type_error_type) { @@ -9844,12 +9841,8 @@ static statement_t *parse_goto(void) } /* remember the goto's in a list for later checking */ - if (goto_last == NULL) { - goto_first = &statement->gotos; - } else { - goto_last->next = &statement->gotos; - } - goto_last = &statement->gotos; + *goto_anchor = &statement->gotos; + goto_anchor = &statement->gotos.next; expect(';');