C++: simplify output from suggest_alternatives_for
[official-gcc.git] / gcc / testsuite / g++.dg / spellcheck-typenames.C
blob25d3f1dcefd8eb322a392f1e7721640e383e00bd
1 /* { dg-do compile } */
2 /* { dg-options "-fdiagnostics-show-caret" } */
4 void test_1 (signed char e);
6 /* PR c/70339.  */
7 void test_2 (singed char e); // { dg-error "21: variable or field 'test_2' declared void" }
8 /* { dg-begin-multiline-output "" }
9  void test_2 (singed char e);
10                      ^~~~
11    { dg-end-multiline-output "" } */
12 // { dg-message "14: 'singed' was not declared in this scope; did you mean 'signed'\\?" "" { target *-*-* } 7 }
13 /* { dg-begin-multiline-output "" }
14  void test_2 (singed char e);
15               ^~~~~~
16               signed
17    { dg-end-multiline-output "" } */
19 void test_3 (car e); // { dg-error "14: variable or field 'test_3' declared void" }
20 /* { dg-begin-multiline-output "" }
21  void test_3 (car e);
22               ^~~
23    { dg-end-multiline-output "" } */
24 // { dg-message "14: 'car' was not declared in this scope; did you mean 'char'\\?" "" { target *-*-* } 19 }
25 /* { dg-begin-multiline-output "" }
26  void test_3 (car e);
27               ^~~
28               char
29    { dg-end-multiline-output "" } */
31 /* TODO: this one could be handled better.  */
32 void test_4 (signed car e); // { dg-error "25: expected ',' or '...' before 'e'" }
33 /* { dg-begin-multiline-output "" }
34  void test_4 (signed car e);
35                          ^
36    { dg-end-multiline-output "" } */
38 /* Verify that we handle misspelled typedef names.  */
40 typedef struct something {} something_t;
42 some_thing_t test_5; // { dg-error "1: 'some_thing_t' does not name a type; did you mean 'something_t'?" }
43   /* { dg-begin-multiline-output "" }
44  some_thing_t test_5;
45  ^~~~~~~~~~~~
46  something_t
47    { dg-end-multiline-output "" } */
49 /* TODO: we don't yet handle misspelled struct names.  */
50 struct some_thing test_6; // { dg-error "aggregate 'some_thing test_6' has incomplete type and cannot be defined" }
51   /* { dg-begin-multiline-output "" }
52  struct some_thing test_6;
53                    ^~~~~~
54    { dg-end-multiline-output "" } */
56 typedef long int64_t;
57 int64 i; // { dg-error "1: 'int64' does not name a type; did you mean 'int64_t'?" }
58 /* { dg-begin-multiline-output "" }
59  int64 i;
60  ^~~~~
61  int64_t
62    { dg-end-multiline-output "" } */
64 /* Verify that gcc doesn't offer nonsensical suggestions.  */
66 nonsensical_suggestion_t var; /* { dg-bogus "did you mean" } */
67 /* { dg-error "'nonsensical_suggestion_t' does not name a type" "" { target { *-*-* } } .-1 } */
68 /* { dg-begin-multiline-output "" }
69  nonsensical_suggestion_t var;
70  ^~~~~~~~~~~~~~~~~~~~~~~~
71    { dg-end-multiline-output "" } */
73 singed char ch; // { dg-error "1: 'singed' does not name a type; did you mean 'signed'?" }
74 /* { dg-begin-multiline-output "" }
75  singed char ch;
76  ^~~~~~
77  signed
78    { dg-end-multiline-output "" } */