diff options
Diffstat (limited to 'parse.c')
-rw-r--r-- | parse.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -726,12 +726,14 @@ static struct symbol * alloc_indirect_symbol(struct position pos, struct ctype * * it also ends up using function scope instead of the * regular symbol scope. */ -struct symbol *label_symbol(struct token *token) +struct symbol *label_symbol(struct token *token, int used) { struct symbol *sym = lookup_symbol(token->ident, NS_LABEL); if (!sym) { sym = alloc_symbol(token->pos, SYM_LABEL); bind_symbol(sym, token->ident, NS_LABEL); + if (used) + sym->used = 1; fn_local_symbol(sym); } return sym; @@ -2139,7 +2141,7 @@ static struct token *parse_asm_labels(struct token *token, struct statement *stm token = token->next; /* skip ':' and ',' */ if (token_type(token) != TOKEN_IDENT) return token; - label = label_symbol(token); + label = label_symbol(token, 1); add_symbol(labels, label); token = token->next; } while (match_op(token, ',')); @@ -2509,7 +2511,7 @@ static struct token *parse_goto_statement(struct token *token, struct statement token = parse_expression(token->next, &stmt->goto_expression); add_statement(&function_computed_goto_list, stmt); } else if (token_type(token) == TOKEN_IDENT) { - struct symbol *label = label_symbol(token); + struct symbol *label = label_symbol(token, 1); stmt->goto_label = label; check_label_usage(label, stmt->pos); token = token->next; @@ -2563,7 +2565,7 @@ static struct token *statement(struct token *token, struct statement **tree) return s->op->statement(token, stmt); if (match_op(token->next, ':')) { - struct symbol *s = label_symbol(token); + struct symbol *s = label_symbol(token, 0); token = skip_attributes(token->next->next); if (s->stmt) { sparse_error(stmt->pos, "label '%s' redefined", show_ident(s->ident)); |