PR tree-optimization/81303
[official-gcc.git] / gcc / testsuite / gcc.dg / spellcheck-typenames.c
blob3717ad89f1bd06451ab51e134051bead5558f865
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 "14: unknown type name .singed.; did you mean .signed.?" } */
8 /* { dg-begin-multiline-output "" }
9 void test_2 (singed char e);
10 ^~~~~~
11 signed
12 { dg-end-multiline-output "" } */
14 void test_3 (car e); /* { dg-error "14: unknown type name .car.; did you mean .char.?" } */
15 /* { dg-begin-multiline-output "" }
16 void test_3 (car e);
17 ^~~
18 char
19 { dg-end-multiline-output "" } */
21 /* TODO: this one could be handled better. */
22 void test_4 (signed car e); /* { dg-error "25: before .e." } */
23 /* { dg-begin-multiline-output "" }
24 void test_4 (signed car e);
26 { dg-end-multiline-output "" } */
28 /* Verify that we handle misspelled typedef names. */
30 typedef struct something {} something_t;
32 some_thing_t test_5; /* { dg-error "1: unknown type name .some_thing_t.; did you mean .something_t.?" } */
33 /* { dg-begin-multiline-output "" }
34 some_thing_t test_5;
35 ^~~~~~~~~~~~
36 something_t
37 { dg-end-multiline-output "" } */
39 /* TODO: we don't yet handle misspelled struct names. */
40 struct some_thing test_6; /* { dg-error "storage size of .test_6. isn't known" } */
41 /* { dg-begin-multiline-output "" }
42 struct some_thing test_6;
43 ^~~~~~
44 { dg-end-multiline-output "" } */
46 typedef long int64_t;
47 int64 i; /* { dg-error "unknown type name 'int64'; did you mean 'int64_t'?" } */
48 /* { dg-begin-multiline-output "" }
49 int64 i;
50 ^~~~~
51 int64_t
52 { dg-end-multiline-output "" } */
54 /* Verify that gcc doesn't offer nonsensical suggestions. */
56 nonsensical_suggestion_t var; /* { dg-bogus "did you mean" } */
57 /* { dg-error "unknown type name" "" { target { *-*-* } } .-1 } */
58 /* { dg-begin-multiline-output "" }
59 nonsensical_suggestion_t var;
60 ^~~~~~~~~~~~~~~~~~~~~~~~
61 { dg-end-multiline-output "" } */
64 /* In the following, we should suggest inserting "struct" (rather
65 than "did you mean 'float'") and provide a fixit hint. */
66 struct foo_t {
67 int i;
69 foo_t *foo_ptr; /* { dg-error "1: unknown type name .foo_t.; use .struct. keyword to refer to the type" } */
70 /* { dg-begin-multiline-output "" }
71 foo_t *foo_ptr;
72 ^~~~~
73 struct
74 { dg-end-multiline-output "" } */
77 /* Similarly for unions. */
78 union bar_t {
79 int i;
80 char j;
82 bar_t *bar_ptr; /* { dg-error "1: unknown type name .bar_t.; use .union. keyword to refer to the type" } */
83 /* { dg-begin-multiline-output "" }
84 bar_t *bar_ptr;
85 ^~~~~
86 union
87 { dg-end-multiline-output "" } */
90 /* Similarly for enums. */
91 enum baz {
92 BAZ_FIRST,
93 BAZ_SECOND
95 baz value; /* { dg-error "1: unknown type name .baz.; use .enum. keyword to refer to the type" } */
96 /* { dg-begin-multiline-output "" }
97 baz value;
98 ^~~
99 enum
100 { dg-end-multiline-output "" } */
102 /* TODO: it would be better to detect the "singed" vs "signed" typo here. */
103 singed char ch; /* { dg-error "7: before .char." } */
104 /* { dg-begin-multiline-output "" }
105 singed char ch;
106 ^~~~~
108 { dg-end-multiline-output "" } */