From: Dan Carpenter <error27@gmail.com>
To: linux-sparse@vger.kernel.org
Subject: declarations after a case statement
Date: Thu, 4 Jun 2026 16:40:44 +0300 [thread overview]
Message-ID: <aiGAXJhYJoUuqB5j@stanley.mountain> (raw)
Sparse doesn't let you declare a variable immediately after a case
statement but that's something we do in the kernel these days. The
"b" declaration is fine, but "c" generates a warning.
regards,
dan carpenter
$ ./sparse test.c
test.c:10:17: error: typename in expression
test.c:10:21: error: Expected ; at end of statement
test.c:10:21: error: got c
test.c:10:17: error: undefined identifier 'int'
$
#include <stdio.h>
void func(int a)
{
switch (a) {
case 1:
printf("hello\n");
int b;
case 2:
int c;
}
}
next reply other threads:[~2026-06-04 13:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-04 13:40 Dan Carpenter [this message]
2026-06-04 13:48 ` declarations after a case statement Dan Carpenter
2026-06-04 14:21 ` Derek M Jones
2026-06-05 5:50 ` Dan Carpenter
2026-06-05 10:43 ` Derek M Jones
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=aiGAXJhYJoUuqB5j@stanley.mountain \
--to=error27@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