1 /* { dg-do compile } */
2 /* { dg-options "-fdiagnostics-show-caret" } */
3
4 struct foo { int x; };
5 union u { int x; };
6
7 /* Verify that we issue a hint for "." used with a ptr to a struct. */
8
test_1(struct foo * ptr)9 int test_1 (struct foo *ptr)
10 {
11 return ptr.x; /* { dg-error "'ptr' is a pointer; did you mean to use '->'?" } */
12 /* { dg-begin-multiline-output "" }
13 return ptr.x;
14 ^
15 ->
16 { dg-end-multiline-output "" } */
17 }
18
19 /* Likewise for a ptr to a union. */
20
test_2(union u * ptr)21 int test_2 (union u *ptr)
22 {
23 return ptr.x; /* { dg-error "'ptr' is a pointer; did you mean to use '->'?" } */
24 /* { dg-begin-multiline-output "" }
25 return ptr.x;
26 ^
27 ->
28 { dg-end-multiline-output "" } */
29 }
30
31 /* Verify that we don't issue a hint for a ptr to something that isn't a
32 struct or union. */
33
test_3(void ** ptr)34 int test_3 (void **ptr)
35 {
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;
39 ^
40 { dg-end-multiline-output "" } */
41 }
42