Issue a warning if a label is defined but not used. Note: this should take in account the attribute 'unused'. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> --- scope.c | 8 ++++++++ validation/label-unused.c | 1 - 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/scope.c b/scope.c index 017c0dcd8600..03593d823d6d 100644 --- a/scope.c +++ b/scope.c @@ -150,6 +150,14 @@ void start_label_scope(void) void end_label_scope(void) { + struct symbol *sym; + + FOR_EACH_PTR(label_scope->symbols, sym) { + if (!sym->stmt || sym->used) + continue; + warning(sym->pos, "unused label '%s'", show_ident(sym->ident)); + } END_FOR_EACH_PTR(sym); + end_scope(&label_scope); } diff --git a/validation/label-unused.c b/validation/label-unused.c index c136c7a8813e..a654ef7742be 100644 --- a/validation/label-unused.c +++ b/validation/label-unused.c @@ -15,7 +15,6 @@ l: /* * check-name: label-unused - * check-known-to-fail * * check-error-start label-unused.c:3:1: warning: unused label 'l' -- 2.26.2