declarations after a case statement

Dan Carpenter <[email protected]> Thu, 4 Jun 2026 16:40:44 +0300
Newsgroups org.kernel.vger.linux-sparse
Message-ID <[email protected]>
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;
	}
}