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@xxxxxxxxx> --- parse.c | 9 ++++++--- validation/label-redefined.c | 1 - 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/parse.c b/parse.c index d94c53a22..1f5fa3a41 100644 --- a/parse.c +++ b/parse.c @@ -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 5e0a51b41..c98e815c1 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 -- 2.17.0 -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html