blob: 482f265e2cb1da02142dbebac1d05563bcadad36 (
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
/* $NetBSD: d_struct_init_nested.c,v 1.8 2023/03/28 14:44:34 rillig Exp $ */
# 3 "d_struct_init_nested.c"
/*
* Initialization of a nested struct, in which some parts are initialized
* from non-constant expressions of the inner struct type.
*
* In C99, 6.7.8p13 describes exactly this case.
*/
/* lint1-extra-flags: -X 351 */
typedef enum O1 { O1C = 101 } O1;
typedef enum O2 { O2C = 102 } O2;
typedef enum O3 { O3C = 103 } O3;
typedef enum I1 { I1C = 201 } I1;
typedef enum I2 { I2C = 202 } I2;
struct Inner1 {
I1 i1;
};
struct Outer3Inner1 {
O1 o1;
struct Inner1 inner;
O3 o3;
};
O1
funcOuter3Inner1(void)
{
struct Inner1 inner = {
I1C
};
struct Outer3Inner1 o3i1 = {
O1C,
inner,
O3C
};
return o3i1.o1;
}
struct Inner2 {
I1 i1;
I2 i2;
};
struct Outer3Inner2 {
O1 o1;
struct Inner2 inner;
O3 o3;
};
O1
funcOuter3Inner2(void)
{
struct Inner2 inner = {
I1C,
I2C
};
struct Outer3Inner2 o3i2 = {
O1C,
inner,
O3C
};
return o3i2.o1;
}
/*
* For static storage duration, each initializer expression must be a constant
* expression.
*/
struct Inner2 inner = {
I1C,
I2C
};
struct Outer3Inner2 o3i2 = {
O1C,
/* expect+1: error: non-constant initializer [177] */
inner,
O3C
};
|