* handling C99 declarations after a case statement
@ 2022-08-12 9:48 Dan Carpenter
0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2022-08-12 9:48 UTC (permalink / raw)
To: linux-sparse
The kernel recently "moved to modern C99". https://lwn.net/Articles/885941/
We still have the -Wdeclaration-after-statement but one thing that we
can do now which trips up Sparse is declare variables immediately
after a case statement.
int x;
int test(void)
{
switch (x) {
case 4:
int a; <-- before you would have to add {} around this
break;
}
}
Sparse makes the "int a" into a STMT_EXPRESSION instead of a
STMT_DECLARATION and test-inspect doesn't like it:
$ ./test-inspect test.c
test.c:7:17: error: typename in expression
test.c:7:21: error: Expected ; at end of statement
test.c:7:21: error: got a
test.c:7:17: error: undefined identifier 'int'
This causes a Smatch warning as well about a statement without any
effect. The first code to trigger this was introduced in linux-next
yesterday.
regards,
dan carpenter
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-08-12 9:48 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-12 9:48 handling C99 declarations after a case statement Dan Carpenter
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.