2018-01-10 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / spellcheck-fields-3.c
blob003a0b5ea26611d828f2736d7380d5b49609bfb7
1 /* { dg-do compile } */
2 /* { dg-options "-fdiagnostics-show-caret -std=c99" } */
4 /* Tests of incorrect name initializers.
5 Verify that we get underlines and, where appropriate, fixit hints. */
7 struct foo
9 int foo;
10 int bar;
13 union u
15 int color;
16 int shape;
19 /* Old-style named initializers. */
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 "" } */
29 this_does_not_match: 3 /* { dg-error ".struct foo. has no member named .this_does_not_match." } */
31 /* { dg-begin-multiline-output "" }
32 this_does_not_match: 3
33 ^~~~~~~~~~~~~~~~~~~
34 { dg-end-multiline-output "" } */
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 "" } */
44 /* C99-style named initializers. */
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 "" } */
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 "" } */
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 "" } */