diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-05-26 18:20:04 +0200 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-05-26 18:35:46 +0200 |
| commit | bfa07811d74a583c2bcefb47162601b997843cdc (patch) | |
| tree | c21e8c49f2ef3ca18f7b4140e8a91f3f0d21795b | |
| parent | 8efcdf62178fd8cb97d1626443dcf560c1d895b8 (diff) | |
| download | sparse-dev-bfa07811d74a583c2bcefb47162601b997843cdc.tar.gz | |
label: avoid multiple definitions
If a label is defined several times, an error is issued about it.
Nevertheless, the label is used as is and once the code is linearized
several BB are created for the same label and this create
inconsistencies. For example, some code will trigger assertion failures
in rewrite_parent_branch().
Avoid the consistencies by ignoring redefined labels.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
| -rw-r--r-- | parse.c | 9 | ||||
| -rw-r--r-- | validation/label-redefined.c | 1 |
2 files changed, 6 insertions, 4 deletions
@@ -2395,12 +2395,15 @@ static struct token *statement(struct token *token, struct statement **tree) if (match_op(token->next, ':')) { struct symbol *s = label_symbol(token); + token = skip_attributes(token->next->next); + if (s->stmt) { + sparse_error(stmt->pos, "label '%s' redefined", show_ident(s->ident)); + // skip the label to avoid multiple definitions + return statement(token, tree); + } stmt->type = STMT_LABEL; stmt->label_identifier = s; - if (s->stmt) - sparse_error(stmt->pos, "label '%s' redefined", show_ident(token->ident)); s->stmt = stmt; - token = skip_attributes(token->next->next); return statement(token, &stmt->label_statement); } } diff --git a/validation/label-redefined.c b/validation/label-redefined.c index 5e0a51b4..c98e815c 100644 --- a/validation/label-redefined.c +++ b/validation/label-redefined.c @@ -10,7 +10,6 @@ l: /* * check-name: label-redefined - * check-known-to-fail * * check-error-start label-redefined.c:7:1: error: label 'l' redefined |
