xref: /netbsd-src/tests/usr.bin/xlint/lint1/init_c90.c (revision b2baa50111d645353fa30b4deab0f79d93650c8c)
1 /*	$NetBSD: init_c90.c,v 1.5 2023/03/28 14:44:34 rillig Exp $	*/
2 # 3 "init_c90.c"
3 
4 /*
5  * Test initialization before C99.
6  *
7  * C90 3.5.7
8  */
9 
10 /* lint1-flags: -sw -X 351 */
11 
12 struct point {
13 	int x, y;
14 };
15 
16 struct point point_c90 = { 0, 0 };
17 /* expect+2: warning: struct or union member name in initializer is a C99 feature [313] */
18 /* expect+1: warning: struct or union member name in initializer is a C99 feature [313] */
19 struct point point_c99 = { .x = 0, .y = 0 };
20 
21 struct point points_c90[] = {{ 0, 0 }};
22 /* expect+1: warning: array initializer with designators is a C99 feature [321] */
23 struct point points_c99[] = {[3] = { 0, 0 }};
24 
25 
26 struct point
compound_literal(void)27 compound_literal(void) {
28 	/* expect+1: error: compound literals are a C99/GCC extension [319] */
29 	return (struct point){ 0, 0 };
30 }
31