xref: /netbsd-src/tests/usr.bin/xlint/lint1/msg_163.c (revision 7d62b00eb9ad855ffcd7da46b41e23feb5476fac)
1 /*	$NetBSD: msg_163.c,v 1.4 2021/07/04 12:24:39 rillig Exp $	*/
2 # 3 "msg_163.c"
3 
4 // Test for message: a cast does not yield an lvalue [163]
5 
6 void
7 example(char *p, int i)
8 {
9 	p++;
10 
11 	/*
12 	 * Using a cast as an lvalue had been a GCC extension until 3.4.
13 	 * It was removed in GCC 4.0.
14 	 *
15 	 * https://gcc.gnu.org/onlinedocs/gcc-3.4.6/gcc/Lvalues.html#Lvalues
16 	 * https://gcc.gnu.org/onlinedocs/gcc-4.0.4/gcc/index.html#toc_C-Extensions
17 	 */
18 	/* expect+2: error: a cast does not yield an lvalue [163] */
19 	/* expect+1: error: operand of 'x++' must be lvalue [114] */
20 	((char *)p)++;
21 
22 	i++;
23 
24 	/* expect+2: error: a cast does not yield an lvalue [163] */
25 	/* expect+1: error: operand of 'x++' must be lvalue [114] */
26 	((int)i)++;
27 }
28