summaryrefslogtreecommitdiff
path: root/tests/usr.bin/xlint/lint1/decl_struct_c90.c
blob: 57d1ec80ddc202b76267474eb2b971f96bf74f37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*	$NetBSD: decl_struct_c90.c,v 1.4 2022/02/27 11:40:30 rillig Exp $	*/
# 3 "decl_struct_c90.c"

/*
 * Test declaration of struct types, in C90 without any GNU extensions.
 */

/* lint1-flags: -sw */

struct unnamed_member {
	enum { A, B, C } tag;
	union {
		int a_value;
		void *b_value;
		void (*c_value)(void);
	};
	/* expect-1: warning: anonymous struct/union members is a C11 feature [49] */
};

/*
 * All of K&R, C90, C99 require that a struct member declaration is
 * terminated with a semicolon.
 *
 * Before cgram.y 1.328 from 2021-07-15, lint allowed the missing semicolon
 * in non-C90 mode, no idea why.
 */
struct missing_semicolon {
	int member
};
/* expect-1: error: syntax error '}' [249] */
/* expect+1: error: cannot recover from previous errors [224] */