init.c revision 1.2
1/*	$NetBSD: init.c,v 1.2 2021/12/17 01:00:50 rillig Exp $	*/
2# 3 "init.c"
3
4/*
5 * Tests for initialization.
6 *
7 * C99 6.7.8
8 */
9
10/*
11 * C99 does not allow empty initializer braces syntactically.
12 * Lint allows this syntactically, it just complains if the resulting
13 * object is empty.
14 */
15/* expect+1: error: empty array declaration: empty_array_with_initializer [190] */
16double empty_array_with_initializer[] = {};
17double array_with_empty_initializer[3] = {};
18
19/*
20 * C99 does not allow empty initializer braces syntactically.
21 */
22struct {
23	int member;
24} empty_struct_initializer = {};
25
26
27typedef struct {
28	const char *key;
29	int n;
30} histogram_entry;
31
32/*
33 * The C standards allow omitting braces around the structural levels.  For
34 * human readers, it is usually clearer to include them.
35 *
36 * Seen in external/ibm-public/postfix/dist/src/util/dict.c(624).
37 */
38const histogram_entry hgr[] = {
39	/* expect+1: error: cannot initialize 'struct typedef histogram_entry' from 'pointer to char' [185] */
40	"odd", 5,
41	"even", 5,
42};
43