C++: simplify output from suggest_alternatives_for
[official-gcc.git] / gcc / testsuite / g++.dg / spellcheck-identifiers.C
bloba9521af8c53aaf15e09869c82b08e80c744f7535
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; did you mean 'gtk_widget_show_all'\\?" }
13   /* { dg-begin-multiline-output "" }
14    gtk_widget_showall (w);
15    ^~~~~~~~~~~~~~~~~~
16    gtk_widget_show_all
17    { dg-end-multiline-output "" } */
19   /* Ensure we don't try to suggest "gtk_widget_showall" for subsequent
20      corrections.  */
21   gtk_widget_showall_ (w); // { dg-error "3: 'gtk_widget_showall_' was not declared in this scope; did you mean 'gtk_widget_show_all'\\?" }
22   /* { dg-begin-multiline-output "" }
23    gtk_widget_showall_ (w);
24    ^~~~~~~~~~~~~~~~~~~
25    gtk_widget_show_all
26    { dg-end-multiline-output "" } */
28   GtkWidgetShowAll (w); // { dg-error "3: 'GtkWidgetShowAll' was not declared in this scope; did you mean 'gtk_widget_show_all'\\?" }
29   /* { dg-begin-multiline-output "" }
30    GtkWidgetShowAll (w);
31    ^~~~~~~~~~~~~~~~
32    gtk_widget_show_all
33    { dg-end-multiline-output "" } */
36 int
37 test_2 (int param)
39   return parma * parma; // { dg-error "10: 'parma' was not declared in this scope; did you mean 'param'\\?" }
40   /* { dg-begin-multiline-output "" }
41    return parma * parma;
42           ^~~~~
43           param
44    { dg-end-multiline-output "" } */
47 #define MACRO(X) ((X))
49 int
50 test_3 (int i)
52   return MACRAME (i); // { dg-error "10: 'MACRAME' was not declared in this scope; did you mean 'MACRO'\\?" }
53   /* { dg-begin-multiline-output "" }
54    return MACRAME (i);
55           ^~~~~~~
56           MACRO
57    { dg-end-multiline-output "" } */
60 #define IDENTIFIER_POINTER(X) ((X))
62 int
63 test_4 (int node)
65   return IDENTIFIER_PTR (node); // { dg-error "10: 'IDENTIFIER_PTR' was not declared in this scope; did you mean 'IDENTIFIER_POINTER'\\?" }
66   /* { dg-begin-multiline-output "" }
67    return IDENTIFIER_PTR (node);
68           ^~~~~~~~~~~~~~
69           IDENTIFIER_POINTER
70    { dg-end-multiline-output "" } */
74 int
75 test_5 (void)
77   return __LINE_; /* { dg-error "10: '__LINE_' was not declared in this scope; did you mean '__LINE__'\\?" }
78   /* { dg-begin-multiline-output "" }
79    return __LINE_;
80           ^~~~~~~
81           __LINE__
82    { dg-end-multiline-output "" } */
85 #define MAX_ITEMS 100
86 int array[MAX_ITEM]; // { dg-error "11: 'MAX_ITEM' was not declared in this scope; did you mean 'MAX_ITEMS'\\?" }
87   /* { dg-begin-multiline-output "" }
88  int array[MAX_ITEM];
89            ^~~~~~~~
90            MAX_ITEMS
91    { dg-end-multiline-output "" } */
94 enum foo {
95   FOO_FIRST,
96   FOO_SECOND
99 void
100 test_6 (enum foo f)
102   switch (f)
103     {
104     case FOO_FURST: // { dg-error "10: 'FOO_FURST' was not declared in this scope; did you mean 'FOO_FIRST'\\?" }
105       break;
106   /* { dg-begin-multiline-output "" }
107      case FOO_FURST:
108           ^~~~~~~~~
109           FOO_FIRST
110    { dg-end-multiline-output "" } */
112     case FOO_SECCOND: // { dg-error "10: 'FOO_SECCOND' was not declared in this scope; did you mean 'FOO_SECOND'\\?" }
113       break;
114   /* { dg-begin-multiline-output "" }
115      case FOO_SECCOND:
116           ^~~~~~~~~~~
117           FOO_SECOND
118    { dg-end-multiline-output "" } */
120     default:
121       break;
122     }
125 int snprintf (char *, __SIZE_TYPE__, const char *, ...);
127 void
128 test_7 (int i, int j)
130   int buffer[100];
131   snprint (buffer, 100, "%i of %i", i, j); // { dg-error "3: 'snprint' was not declared in this scope; did you mean 'snprintf'\\?" }
132   /* { dg-begin-multiline-output "" }
133    snprint (buffer, 100, "%i of %i", i, j);
134    ^~~~~~~
135    snprintf
136    { dg-end-multiline-output "" } */
140 test_8 ()
142   int local = 42;
143   
144   return locale; // { dg-error "10: 'locale' was not declared in this scope; did you mean 'local'\\?" }
145   /* { dg-begin-multiline-output "" }
146    return locale;
147           ^~~~~~
148           local
149    { dg-end-multiline-output "" } */
152 class base
154 public:
155   int test_method_1 ();
157 protected:
158   int m_foo;
161 class sub : public base
163 public:
164   int test_method_2 ();
167 int base::test_method_1 ()
169   return m_food; // { dg-error "10: 'm_food' was not declared in this scope; did you mean 'm_foo'\\?" }
170   /* { dg-begin-multiline-output "" }
171    return m_food;
172           ^~~~~~
173           m_foo
174    { dg-end-multiline-output "" } */
177 int sub::test_method_2 ()
179   return m_food; // { dg-error "10: 'm_food' was not declared in this scope; did you mean 'm_foo'\\?" }
180   /* { dg-begin-multiline-output "" }
181    return m_food;
182           ^~~~~~
183           m_foo
184    { dg-end-multiline-output "" } */