xref: /netbsd-src/tests/usr.bin/xlint/lint1/msg_022.c (revision 3d6a50253cd682dca85a66a49baee893251dac65)
1 /*	$NetBSD: msg_022.c,v 1.8 2025/01/03 03:14:47 rillig Exp $	*/
2 # 3 "msg_022.c"
3 
4 // Test for message: incomplete or misplaced function definition [22]
5 
6 /* lint1-extra-flags: -X 351 */
7 
8 /*
9  * Before decl.c 1.264 and func.c 1.130 from 2022-04-02, lint ran into
10  * assertion failures after trying to recover from the below syntax error.
11  */
12 /* expect+1: error: syntax error 'f' [249] */
13 unsigned long asdf = sizeof(int f() {});
14 
15 /* Give the parser a chance to recover. */
16 /* expect+1: warning: empty declaration [0] */
17 ;
18 
19 /*
20  * Before decl.c 1.264 and func.c 1.130 from 2022-04-02, lint ran into
21  * assertion failures after trying to recover from the below syntax error.
22  */
23 /* expect+1: error: syntax error 'param1' [249] */
24 unsigned long sz = sizeof(int(param1, param2));
25 
26 /* Give the parser a chance to recover. */
27 /* expect+1: warning: empty declaration [0] */
28 ;
29 
30 /* expect+3: warning: function definition for 'old_style' with identifier list is obsolete in C23 [384] */
31 /* expect+2: error: incomplete or misplaced function definition [22] */
32 /* expect+1: warning: old-style declaration; add 'int' [1] */
33 old_style(arg);
34