[PR c++/84702] ICE with default tmpl arg of overload set
[official-gcc.git] / gcc / testsuite / g++.dg / spellcheck-fields.C
blob504992aa541e38ec458773c6ba582a5eb3f21540
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 has_anon::<unnamed>' has no member named 'colour'; did you mean 'color'?" } */
65 int test8 (foo &ref)
67   return ref.m_bar; /* { dg-error "'struct foo' has no member named 'm_bar'; did you mean 'bar'?" } */
70 struct bar : public foo
72   int fizz;
73   typedef int my_type;
76 int test9 (bar *ptr)
78   return ptr->fuzz; /* { dg-error "'struct bar' has no member named 'fuzz'; did you mean 'fizz'?" } */
81 int test10 (bar *ptr)
83   return ptr->m_foo; /* { dg-error "'struct bar' has no member named 'm_foo'; did you mean 'foo'?" } */
86 int test11 (bar *ptr)
88   return ptr->mytype; /* { dg-error "'struct bar' has no member named 'mytype'; did you mean 'my_type'?" } */