PR middle-end/77357 - strlen of constant strings not folded
[official-gcc.git] / gcc / testsuite / gcc.dg / spellcheck-fields.c
blob44e05e55423af2ad882fe7ca5e23926157584367
1 /* { dg-do compile } */
3 struct foo
5 int foo;
6 int bar;
7 int baz;
8 };
10 int test (struct foo *ptr)
12 return ptr->m_bar; /* { dg-error "'struct foo' has no member named 'm_bar'; did you mean 'bar'?" } */
15 int test2 (void)
17 struct foo instance = {0, 0, 0};
18 return instance.m_bar; /* { dg-error "'struct foo' has no member named 'm_bar'; did you mean 'bar'?" } */
21 struct s {
22 struct j { int aa; } kk;
23 int ab;
26 void test3 (struct s x)
28 x.ac; /* { dg-error "'struct s' has no member named 'ac'; did you mean 'ab'?" } */
31 int test4 (struct foo *ptr)
33 return sizeof (ptr->foa); /* { dg-error "'struct foo' has no member named 'foa'; did you mean 'foo'?" } */
36 /* Verify that we don't offer nonsensical suggestions. */
38 int test5 (struct foo *ptr)
40 return ptr->this_is_unlike_any_of_the_fields; /* { dg-bogus "did you mean" } */
41 /* { dg-error "has no member named" "" { target *-*-* } .-1 } */
44 union u
46 int color;
47 int shape;
50 int test6 (union u *ptr)
52 return ptr->colour; /* { dg-error "'union u' has no member named 'colour'; did you mean 'color'?" } */
55 struct has_anon
57 struct { int color; } s;
60 int test7 (struct has_anon *ptr)
62 return ptr->s.colour; /* { dg-error "'struct <anonymous>' has no member named 'colour'; did you mean 'color'?" } */