(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
spellcheck-fields.c
       1  /* { dg-do compile } */
       2  
       3  struct foo
       4  {
       5    int foo;
       6    int bar;
       7    int baz;
       8  };
       9  
      10  int test (struct foo *ptr)
      11  {
      12    return ptr->m_bar; /* { dg-error "'struct foo' has no member named 'm_bar'; did you mean 'bar'?" } */
      13  }
      14  
      15  int test2 (void)
      16  {
      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'?" } */
      19  }
      20  
      21  struct s {
      22      struct j { int aa; } kk;
      23      int ab;
      24  };
      25  
      26  void test3 (struct s x)
      27  {
      28    x.ac;  /* { dg-error "'struct s' has no member named 'ac'; did you mean 'ab'?" } */
      29  }
      30  
      31  int test4 (struct foo *ptr)
      32  {
      33    return sizeof (ptr->foa); /* { dg-error "'struct foo' has no member named 'foa'; did you mean 'foo'?" } */
      34  }
      35  
      36  /* Verify that we don't offer nonsensical suggestions.  */
      37  
      38  int test5 (struct foo *ptr)
      39  {
      40    return ptr->this_is_unlike_any_of_the_fields;   /* { dg-bogus "did you mean" } */
      41    /* { dg-error "has no member named" "" { target *-*-* } .-1 } */
      42  }
      43  
      44  union u
      45  {
      46    int color;
      47    int shape;
      48  };
      49  
      50  int test6 (union u *ptr)
      51  {
      52    return ptr->colour; /* { dg-error "'union u' has no member named 'colour'; did you mean 'color'?" } */
      53  }
      54  
      55  struct has_anon
      56  {
      57    struct { int color; } s;
      58  };
      59  
      60  int test7 (struct has_anon *ptr)
      61  {
      62    return ptr->s.colour; /* { dg-error "'struct <anonymous>' has no member named 'colour'; did you mean 'color'?" } */
      63  }