1 /* { dg-do compile } */
2 /* { dg-options "-fdiagnostics-show-caret -std=c99" } */
3
4 /* Tests of incorrect name initializers.
5 Verify that we get underlines and, where appropriate, fixit hints. */
6
7 struct foo
8 {
9 int foo;
10 int bar;
11 };
12
13 union u
14 {
15 int color;
16 int shape;
17 };
18
19 /* Old-style named initializers. */
20
21 struct foo old_style_f = {
22 foa: 1, /* { dg-error ".struct foo. has no member named .foa.; did you mean .foo." } */
23 /* { dg-begin-multiline-output "" }
24 foa: 1,
25 ^~~
26 foo
27 { dg-end-multiline-output "" } */
28
29 this_does_not_match: 3 /* { dg-error ".struct foo. has no member named .this_does_not_match." } */
30
31 /* { dg-begin-multiline-output "" }
32 this_does_not_match: 3
33 ^~~~~~~~~~~~~~~~~~~
34 { dg-end-multiline-output "" } */
35 };
36
37 union u old_style_u = { colour: 3 }; /* { dg-error ".union u. has no member named .colour.; did you mean .color.?" } */
38 /* { dg-begin-multiline-output "" }
39 union u old_style_u = { colour: 3 };
40 ^~~~~~
41 color
42 { dg-end-multiline-output "" } */
43
44 /* C99-style named initializers. */
45
46 struct foo c99_style_f = {
47 .foa = 1, /* { dg-error ".struct foo. has no member named .foa.; did you mean .foo." } */
48 /* { dg-begin-multiline-output "" }
49 .foa = 1,
50 ^~~
51 foo
52 { dg-end-multiline-output "" } */
53
54 .this_does_not_match = 3 /* { dg-error ".struct foo. has no member named .this_does_not_match." } */
55 /* { dg-begin-multiline-output "" }
56 .this_does_not_match = 3
57 ^~~~~~~~~~~~~~~~~~~
58 { dg-end-multiline-output "" } */
59 };
60
61 union u c99_style_u = { .colour=3 }; /* { dg-error ".union u. has no member named .colour.; did you mean .color.?" } */
62 /* { dg-begin-multiline-output "" }
63 union u c99_style_u = { .colour=3 };
64 ^~~~~~
65 color
66 { dg-end-multiline-output "" } */