[PR c++/84702] ICE with default tmpl arg of overload set
[official-gcc.git] / gcc / testsuite / g++.dg / spellcheck-identifiers.C
blobe4a606e2052a70fb57d83757f5f86788bee34cf7
1 /* { dg-do compile } */
2 /* { dg-options "-fdiagnostics-show-caret" } */
4 typedef struct GtkWidget { int dummy; } GtkWidget;
6 extern void gtk_widget_show_all (GtkWidget *w);
9 void
10 test_1 (GtkWidget *w)
12   gtk_widget_showall (w); // { dg-error "3: 'gtk_widget_showall' was not declared in this scope" }
13   /* { dg-begin-multiline-output "" }
14    gtk_widget_showall (w);
15    ^~~~~~~~~~~~~~~~~~
16    { dg-end-multiline-output "" } */
17   // { dg-message "3: suggested alternative: 'gtk_widget_show_all'" "" { target *-*-* } 12 }
18   /* { dg-begin-multiline-output "" }
19    gtk_widget_showall (w);
20    ^~~~~~~~~~~~~~~~~~
21    gtk_widget_show_all
22    { dg-end-multiline-output "" } */
24   /* Ensure we don't try to suggest "gtk_widget_showall" for subsequent
25      corrections.  */
26   gtk_widget_showall_ (w); // { dg-error "3: 'gtk_widget_showall_' was not declared in this scope" }
27   /* { dg-begin-multiline-output "" }
28    gtk_widget_showall_ (w);
29    ^~~~~~~~~~~~~~~~~~~
30    { dg-end-multiline-output "" } */
31   // { dg-message "3: suggested alternative: 'gtk_widget_show_all'" "" { target *-*-* } 26 }
32   /* { dg-begin-multiline-output "" }
33    gtk_widget_showall_ (w);
34    ^~~~~~~~~~~~~~~~~~~
35    gtk_widget_show_all
36    { dg-end-multiline-output "" } */
38   GtkWidgetShowAll (w); // { dg-error "3: 'GtkWidgetShowAll' was not declared in this scope" }
39   /* { dg-begin-multiline-output "" }
40    GtkWidgetShowAll (w);
41    ^~~~~~~~~~~~~~~~
42    { dg-end-multiline-output "" } */
43   // { dg-message "3: suggested alternative: 'gtk_widget_show_all'" "" { target *-*-* } 38 }
44   /* { dg-begin-multiline-output "" }
45    GtkWidgetShowAll (w);
46    ^~~~~~~~~~~~~~~~
47    gtk_widget_show_all
48    { dg-end-multiline-output "" } */
51 int
52 test_2 (int param)
54   return parma * parma; // { dg-error "10: 'parma' was not declared in this scope" }
55   /* { dg-begin-multiline-output "" }
56    return parma * parma;
57           ^~~~~
58    { dg-end-multiline-output "" } */
59   // { dg-message "10: suggested alternative: 'param'" "" { target *-*-* } 54 }
60   /* { dg-begin-multiline-output "" }
61    return parma * parma;
62           ^~~~~
63           param
64    { dg-end-multiline-output "" } */
67 #define MACRO(X) ((X))
69 int
70 test_3 (int i)
72   return MACRAME (i); // { dg-error "10: 'MACRAME' was not declared in this scope" }
73   /* { dg-begin-multiline-output "" }
74    return MACRAME (i);
75           ^~~~~~~
76    { dg-end-multiline-output "" } */
77   // { dg-message "10: suggested alternative: 'MACRO'" "" { target *-*-* } 72 }
78   /* { dg-begin-multiline-output "" }
79    return MACRAME (i);
80           ^~~~~~~
81           MACRO
82    { dg-end-multiline-output "" } */
85 #define IDENTIFIER_POINTER(X) ((X))
87 int
88 test_4 (int node)
90   return IDENTIFIER_PTR (node); // { dg-error "10: 'IDENTIFIER_PTR' was not declared in this scope" }
91   /* { dg-begin-multiline-output "" }
92    return IDENTIFIER_PTR (node);
93           ^~~~~~~~~~~~~~
94    { dg-end-multiline-output "" } */
95   // { dg-message "10: suggested alternative: 'IDENTIFIER_POINTER'" "" { target *-*-* } 90 }
96   /* { dg-begin-multiline-output "" }
97    return IDENTIFIER_PTR (node);
98           ^~~~~~~~~~~~~~
99           IDENTIFIER_POINTER
100    { dg-end-multiline-output "" } */
105 test_5 (void)
107   return __LINE_; /* { dg-error "10: '__LINE_' was not declared in this scope" }
108   /* { dg-begin-multiline-output "" }
109    return __LINE_;
110           ^~~~~~~
111    { dg-end-multiline-output "" } */
112   // { dg-message "10: suggested alternative: '__LINE__'" "" { target *-*-* } 107 }
113   /* { dg-begin-multiline-output "" }
114    return __LINE_;
115           ^~~~~~~
116           __LINE__
117    { dg-end-multiline-output "" } */
120 #define MAX_ITEMS 100
121 int array[MAX_ITEM]; // { dg-error "11: 'MAX_ITEM' was not declared in this scope" }
122   /* { dg-begin-multiline-output "" }
123  int array[MAX_ITEM];
124            ^~~~~~~~
125    { dg-end-multiline-output "" } */
126   // { dg-message "11: suggested alternative: 'MAX_ITEMS'" "" { target *-*-* } 121 }
127   /* { dg-begin-multiline-output "" }
128  int array[MAX_ITEM];
129            ^~~~~~~~
130            MAX_ITEMS
131    { dg-end-multiline-output "" } */
134 enum foo {
135   FOO_FIRST,
136   FOO_SECOND
139 void
140 test_6 (enum foo f)
142   switch (f)
143     {
144     case FOO_FURST: // { dg-error "10: 'FOO_FURST' was not declared in this scope" }
145       break;
146   /* { dg-begin-multiline-output "" }
147      case FOO_FURST:
148           ^~~~~~~~~
149    { dg-end-multiline-output "" } */
150   // { dg-message "10: suggested alternative: 'FOO_FIRST'" "" { target *-*-* } 144 }
151   /* { dg-begin-multiline-output "" }
152      case FOO_FURST:
153           ^~~~~~~~~
154           FOO_FIRST
155    { dg-end-multiline-output "" } */
157     case FOO_SECCOND: // { dg-error "10: 'FOO_SECCOND' was not declared in this scope" }
158       break;
159   /* { dg-begin-multiline-output "" }
160      case FOO_SECCOND:
161           ^~~~~~~~~~~
162    { dg-end-multiline-output "" } */
163   // { dg-message "10: suggested alternative: 'FOO_SECOND'" "" { target *-*-* } 157 }
164   /* { dg-begin-multiline-output "" }
165      case FOO_SECCOND:
166           ^~~~~~~~~~~
167           FOO_SECOND
168    { dg-end-multiline-output "" } */
170     default:
171       break;
172     }
175 int snprintf (char *, __SIZE_TYPE__, const char *, ...);
177 void
178 test_7 (int i, int j)
180   int buffer[100];
181   snprint (buffer, 100, "%i of %i", i, j); // { dg-error "3: 'snprint' was not declared in this scope" }
182   /* { dg-begin-multiline-output "" }
183    snprint (buffer, 100, "%i of %i", i, j);
184    ^~~~~~~
185    { dg-end-multiline-output "" } */
186   // { dg-message "3: suggested alternative: 'snprintf'" "" { target *-*-* } 181 }
187   /* { dg-begin-multiline-output "" }
188    snprint (buffer, 100, "%i of %i", i, j);
189    ^~~~~~~
190    snprintf
191    { dg-end-multiline-output "" } */
195 test_8 ()
197   int local = 42;
198   
199   return locale; // { dg-error "10: 'locale' was not declared in this scope" }
200   /* { dg-begin-multiline-output "" }
201    return locale;
202           ^~~~~~
203    { dg-end-multiline-output "" } */
204   // { dg-message "10: suggested alternative: 'local'" "" { target *-*-* } 199 }
205   /* { dg-begin-multiline-output "" }
206    return locale;
207           ^~~~~~
208           local
209    { dg-end-multiline-output "" } */
212 class base
214 public:
215   int test_method_1 ();
217 protected:
218   int m_foo;
221 class sub : public base
223 public:
224   int test_method_2 ();
227 int base::test_method_1 ()
229   return m_food; // { dg-error "10: 'm_food' was not declared in this scope" }
230   /* { dg-begin-multiline-output "" }
231    return m_food;
232           ^~~~~~
233    { dg-end-multiline-output "" } */
234   // { dg-message "10: suggested alternative: 'm_foo'" "" { target *-*-* } 229 }
235   /* { dg-begin-multiline-output "" }
236    return m_food;
237           ^~~~~~
238           m_foo
239    { dg-end-multiline-output "" } */
242 int sub::test_method_2 ()
244   return m_food; // { dg-error "10: 'm_food' was not declared in this scope" }
245   /* { dg-begin-multiline-output "" }
246    return m_food;
247           ^~~~~~
248    { dg-end-multiline-output "" } */
249   // { dg-message "10: suggested alternative: 'm_foo'" "" { target *-*-* } 244 }
250   /* { dg-begin-multiline-output "" }
251    return m_food;
252           ^~~~~~
253           m_foo
254    { dg-end-multiline-output "" } */