From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH] handle more graciously labels with no statement
Date: Mon, 26 Oct 2020 05:53:38 +0100 [thread overview]
Message-ID: <20201026045338.55218-1-luc.vanoostenryck@gmail.com> (raw)
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
next reply other threads:[~2020-10-26 4:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-26 4:53 Luc Van Oostenryck [this message]
2020-10-26 17:41 ` [PATCH] handle more graciously labels with no statement 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201026045338.55218-1-luc.vanoostenryck@gmail.com \
--to=luc.vanoostenryck@gmail.com \
--cc=linux-sparse@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).