linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] handle more graciously labels with no statement
@ 2020-10-26  4:53 Luc Van Oostenryck
  2020-10-26 17:41 ` Linus Torvalds
  0 siblings, 1 reply; 6+ messages in thread
From: Luc Van Oostenryck @ 2020-10-26  4:53 UTC (permalink / raw)
  To: linux-sparse; +Cc: Luc Van Oostenryck

In C a label must precede a statement. A null statement is OK
but a closing braces is not.

So, catch this situation, emit a warning and continue as if a
null statement was there.

This occurs currently on v5.10-rc1 because of some ifdefery.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 parse.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/parse.c b/parse.c
index 31ecef0f554d..b6090d38cc61 100644
--- a/parse.c
+++ b/parse.c
@@ -2468,6 +2468,11 @@ static struct token *statement(struct token *token, struct statement **tree)
 					warn_label_usage(stmt->pos, s->label_pos, s->ident);
 			}
 			s->stmt = stmt;
+			if (match_op(token, '}')) {
+				warning(token->pos, "statement expected after label");
+				stmt->label_statement = alloc_statement(token->pos, STMT_NONE);
+				return token;
+			}
 			return statement(token, &stmt->label_statement);
 		}
 	}
-- 
2.29.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-10-26 23:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-26  4:53 [PATCH] handle more graciously labels with no statement Luc Van Oostenryck
2020-10-26 17:41 ` Linus Torvalds
2020-10-26 20:48   ` Luc Van Oostenryck
2020-10-26 22:56     ` Linus Torvalds
2020-10-26 23:22       ` Bart Van Assche
2020-10-26 23:39         ` Linus Torvalds

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).