PR tree-optimization/81303
[official-gcc.git] / gcc / testsuite / gcc.dg / fixits.c
blob06c9995d7ec91b9d197d3461bd463d9a62134483
1 /* { dg-do compile } */
2 /* { dg-options "-fdiagnostics-show-caret" } */
4 struct foo { int x; };
5 union u { int x; };
7 /* Verify that we issue a hint for "." used with a ptr to a struct. */
9 int test_1 (struct foo *ptr)
11 return ptr.x; /* { dg-error "'ptr' is a pointer; did you mean to use '->'?" } */
12 /* { dg-begin-multiline-output "" }
13 return ptr.x;
16 { dg-end-multiline-output "" } */
19 /* Likewise for a ptr to a union. */
21 int test_2 (union u *ptr)
23 return ptr.x; /* { dg-error "'ptr' is a pointer; did you mean to use '->'?" } */
24 /* { dg-begin-multiline-output "" }
25 return ptr.x;
28 { dg-end-multiline-output "" } */
31 /* Verify that we don't issue a hint for a ptr to something that isn't a
32 struct or union. */
34 int test_3 (void **ptr)
36 return ptr.x; /* { dg-error "request for member 'x' in something not a structure or union" } */
37 /* { dg-begin-multiline-output "" }
38 return ptr.x;
40 { dg-end-multiline-output "" } */