flow: fix some parent transition fallout
[smatch.git] / validation / designated-init.c
blob23423e961835493594053037f277cfbc62b79f63
1 struct s1 {
2 int x;
3 int y;
4 };
6 struct s2 {
7 int x;
8 int y;
9 } __attribute__((designated_init));
11 struct nest1 {
12 struct s1 s1;
13 struct s2 s2;
16 struct nest2 {
17 struct s1 s1;
18 struct s2 s2;
19 } __attribute__((designated_init));
21 static struct s1 s1_positional = { 5, 10 };
22 static struct s1 s1_designated = { .x = 5, .y = 10 };
23 static struct s2 s2_positional = { 5, 10 };
24 static struct s2 s2_designated = { .x = 5, .y = 10 };
25 static struct nest1 nest1_positional = {
26 { 5, 10 },
27 { 5, 10 },
29 static struct nest1 nest1_designated_outer = {
30 .s1 = { 5, 10 },
31 .s2 = { 5, 10 },
33 static struct nest1 nest1_designated_inner = {
34 { .x = 5, .y = 10 },
35 { .x = 5, .y = 10 },
37 static struct nest1 nest1_designated_both = {
38 .s1 = { .x = 5, .y = 10 },
39 .s2 = { .x = 5, .y = 10 },
41 static struct nest2 nest2_positional = {
42 { 5, 10 },
43 { 5, 10 },
45 static struct nest2 nest2_designated_outer = {
46 .s1 = { 5, 10 },
47 .s2 = { 5, 10 },
49 static struct nest2 nest2_designated_inner = {
50 { .x = 5, .y = 10 },
51 { .x = 5, .y = 10 },
53 static struct nest2 nest2_designated_both = {
54 .s1 = { .x = 5, .y = 10 },
55 .s2 = { .x = 5, .y = 10 },
58 static struct {
59 int x;
60 int y;
61 } __attribute__((designated_init))
62 anon_positional = { 5, 10 },
63 anon_designated = { .x = 5, .y = 10};
65 static struct s1 s1_array[] = {
66 { 5, 10 },
67 { .x = 5, .y = 10 },
70 static struct s2 s2_array[] = {
71 { 5, 10 },
72 { .x = 5, .y = 10 },
75 static struct s1 ret_s1_positional(void)
77 return ((struct s1){ 5, 10 });
80 static struct s1 ret_s1_designated(void)
82 return ((struct s1){ .x = 5, .y = 10 });
85 static struct s2 ret_s2_positional(void)
87 return ((struct s2){ 5, 10 });
90 static struct s2 ret_s2_designated(void)
92 return ((struct s2){ .x = 5, .y = 10 });
95 static struct nest1 ret_nest1_positional(void)
97 return ((struct nest1){
98 { 5, 10 },
99 { 5, 10 },
103 static struct nest1 ret_nest1_designated_outer(void)
105 return ((struct nest1){
106 .s1 = { 5, 10 },
107 .s2 = { 5, 10 },
111 static struct nest1 ret_nest1_designated_inner(void)
113 return ((struct nest1){
114 { .x = 5, .y = 10 },
115 { .x = 5, .y = 10 },
119 static struct nest1 ret_nest1_designated_both(void)
121 return ((struct nest1){
122 .s1 = { .x = 5, .y = 10 },
123 .s2 = { .x = 5, .y = 10 },
127 static struct nest2 ret_nest2_positional(void)
129 return ((struct nest2){
130 { 5, 10 },
131 { 5, 10 },
135 static struct nest2 ret_nest2_designated_outer(void)
137 return ((struct nest2){
138 .s1 = { 5, 10 },
139 .s2 = { 5, 10 },
143 static struct nest2 ret_nest2_designated_inner(void)
145 return ((struct nest2){
146 { .x = 5, .y = 10 },
147 { .x = 5, .y = 10 },
151 static struct nest2 ret_nest2_designated_both(void)
153 return ((struct nest2){
154 .s1 = { .x = 5, .y = 10 },
155 .s2 = { .x = 5, .y = 10 },
159 * check-name: designated_init attribute
161 * check-error-start
162 designated-init.c:23:36: warning: in initializer for s2_positional: positional init of field in struct s2, declared with attribute designated_init
163 designated-init.c:23:39: warning: in initializer for s2_positional: positional init of field in struct s2, declared with attribute designated_init
164 designated-init.c:27:11: warning: in initializer for s2: positional init of field in struct s2, declared with attribute designated_init
165 designated-init.c:27:14: warning: in initializer for s2: positional init of field in struct s2, declared with attribute designated_init
166 designated-init.c:31:17: warning: in initializer for s2: positional init of field in struct s2, declared with attribute designated_init
167 designated-init.c:31:20: warning: in initializer for s2: positional init of field in struct s2, declared with attribute designated_init
168 designated-init.c:42:9: warning: in initializer for nest2_positional: positional init of field in struct nest2, declared with attribute designated_init
169 designated-init.c:43:9: warning: in initializer for nest2_positional: positional init of field in struct nest2, declared with attribute designated_init
170 designated-init.c:43:11: warning: in initializer for s2: positional init of field in struct s2, declared with attribute designated_init
171 designated-init.c:43:14: warning: in initializer for s2: positional init of field in struct s2, declared with attribute designated_init
172 designated-init.c:47:17: warning: in initializer for s2: positional init of field in struct s2, declared with attribute designated_init
173 designated-init.c:47:20: warning: in initializer for s2: positional init of field in struct s2, declared with attribute designated_init
174 designated-init.c:50:9: warning: in initializer for nest2_designated_inner: positional init of field in struct nest2, declared with attribute designated_init
175 designated-init.c:51:9: warning: in initializer for nest2_designated_inner: positional init of field in struct nest2, declared with attribute designated_init
176 designated-init.c:62:29: warning: in initializer for anon_positional: positional init of field in struct <noident>, declared with attribute designated_init
177 designated-init.c:62:32: warning: in initializer for anon_positional: positional init of field in struct <noident>, declared with attribute designated_init
178 designated-init.c:71:11: warning: in initializer for s2: positional init of field in struct s2, declared with attribute designated_init
179 designated-init.c:71:14: warning: in initializer for s2: positional init of field in struct s2, declared with attribute designated_init
180 designated-init.c:87:30: warning: positional init of field in struct s2, declared with attribute designated_init
181 designated-init.c:87:33: warning: positional init of field in struct s2, declared with attribute designated_init
182 designated-init.c:99:27: warning: in initializer for s2: positional init of field in struct s2, declared with attribute designated_init
183 designated-init.c:99:30: warning: in initializer for s2: positional init of field in struct s2, declared with attribute designated_init
184 designated-init.c:107:33: warning: in initializer for s2: positional init of field in struct s2, declared with attribute designated_init
185 designated-init.c:107:36: warning: in initializer for s2: positional init of field in struct s2, declared with attribute designated_init
186 designated-init.c:130:25: warning: positional init of field in struct nest2, declared with attribute designated_init
187 designated-init.c:131:25: warning: positional init of field in struct nest2, declared with attribute designated_init
188 designated-init.c:131:27: warning: in initializer for s2: positional init of field in struct s2, declared with attribute designated_init
189 designated-init.c:131:30: warning: in initializer for s2: positional init of field in struct s2, declared with attribute designated_init
190 designated-init.c:139:33: warning: in initializer for s2: positional init of field in struct s2, declared with attribute designated_init
191 designated-init.c:139:36: warning: in initializer for s2: positional init of field in struct s2, declared with attribute designated_init
192 designated-init.c:146:25: warning: positional init of field in struct nest2, declared with attribute designated_init
193 designated-init.c:147:25: warning: positional init of field in struct nest2, declared with attribute designated_init
194 * check-error-end