1#define is_constexpr(x) \
2	(sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8)))
3
4static int test(void)
5{
6	unsigned int s = 0, i = 0;
7	void *ptr = &i;
8
9	// OK
10	s += sizeof i;
11	s += sizeof &i;
12	s += sizeof ptr;
13	s += sizeof &ptr;
14
15	// KO
16	s += sizeof(void);
17	s += sizeof *ptr;
18	s += is_constexpr(ptr++);
19	s += is_constexpr((i++, 1));
20	s += is_constexpr(sizeof *ptr);
21	s += is_constexpr(ptr + 1);
22	s += is_constexpr(&ptr + 1);
23	s += is_constexpr(*(((char *)&ptr) + 1));
24
25	return s;
26}
27
28/*
29 * check-name: sizeof(void) is valid
30 * check-description: sizeof(void) was rejected because void is an incomplete
31 * type
32 * check-command: sparse -Wpointer-arith $file
33 *
34 * check-error-start
35sizeof-void.c:16:14: warning: expression using sizeof(void)
36sizeof-void.c:17:14: warning: expression using sizeof(void)
37sizeof-void.c:18:14: warning: expression using sizeof(void)
38sizeof-void.c:19:14: warning: expression using sizeof(void)
39sizeof-void.c:20:14: warning: expression using sizeof(void)
40sizeof-void.c:21:14: warning: expression using sizeof(void)
41sizeof-void.c:22:14: warning: expression using sizeof(void)
42sizeof-void.c:23:14: warning: expression using sizeof(void)
43 * check-error-end
44 */
45