PR target/83368
[official-gcc.git] / gcc / testsuite / gcc.dg / spellcheck-identifiers.c
blob063e3f9eda19a021c2d4a8bca4acf46b1771238c
1 /* { dg-do compile } */
2 /* { dg-options "-Wimplicit-function-declaration -fdiagnostics-show-caret" } */
4 typedef struct GtkWidget { int dummy; } GtkWidget;
6 extern void gtk_widget_show_all (GtkWidget *w);
8 void
9 test_1 (GtkWidget *w)
11 gtk_widget_showall (w); /* { dg-warning "3: implicit declaration of function .gtk_widget_showall.; did you mean .gtk_widget_show_all.?" } */
12 /* { dg-begin-multiline-output "" }
13 gtk_widget_showall (w);
14 ^~~~~~~~~~~~~~~~~~
15 gtk_widget_show_all
16 { dg-end-multiline-output "" } */
18 /* Ensure we don't try to suggest "gtk_widget_showall" for subsequent
19 corrections. */
20 gtk_widget_showall_ (w); /* { dg-warning "3: implicit declaration of function .gtk_widget_showall_.; did you mean .gtk_widget_show_all.?" } */
21 /* { dg-begin-multiline-output "" }
22 gtk_widget_showall_ (w);
23 ^~~~~~~~~~~~~~~~~~~
24 gtk_widget_show_all
25 { dg-end-multiline-output "" } */
27 GtkWidgetShowAll (w); /* { dg-warning "3: implicit declaration of function .GtkWidgetShowAll.; did you mean .gtk_widget_show_all.?" } */
28 /* { dg-begin-multiline-output "" }
29 GtkWidgetShowAll (w);
30 ^~~~~~~~~~~~~~~~
31 gtk_widget_show_all
32 { dg-end-multiline-output "" } */
35 int
36 test_2 (int param)
38 return parma * parma; /* { dg-error "10: .parma. undeclared .first use in this function.; did you mean .param." } */
39 /* { dg-begin-multiline-output "" }
40 return parma * parma;
41 ^~~~~
42 param
43 { dg-end-multiline-output "" } */
46 #define MACRO(X) ((X))
48 int
49 test_3 (int i)
51 return MACRAME (i); /* { dg-warning "10: implicit declaration of function .MACRAME.; did you mean .MACRO.?" } */
52 /* { dg-begin-multiline-output "" }
53 return MACRAME (i);
54 ^~~~~~~
55 MACRO
56 { dg-end-multiline-output "" } */
59 #define IDENTIFIER_POINTER(X) ((X))
61 int
62 test_4 (int node)
64 return IDENTIFIER_PTR (node); /* { dg-warning "10: implicit declaration of function .IDENTIFIER_PTR.; did you mean .IDENTIFIER_POINTER.?" } */
65 /* { dg-begin-multiline-output "" }
66 return IDENTIFIER_PTR (node);
67 ^~~~~~~~~~~~~~
68 IDENTIFIER_POINTER
69 { dg-end-multiline-output "" } */
73 int
74 test_5 (void)
76 return __LINE_; /* { dg-error "10: .__LINE_. undeclared .first use in this function.; did you mean .__LINE__." } */
77 /* { dg-begin-multiline-output "" }
78 return __LINE_;
79 ^~~~~~~
80 __LINE__
81 { dg-end-multiline-output "" } */
84 #define MAX_ITEMS 100
85 int array[MAX_ITEM]; /* { dg-error "11: .MAX_ITEM. undeclared here .not in a function.; did you mean .MAX_ITEMS." } */
86 /* { dg-begin-multiline-output "" }
87 int array[MAX_ITEM];
88 ^~~~~~~~
89 MAX_ITEMS
90 { dg-end-multiline-output "" } */
93 enum foo {
94 FOO_FIRST,
95 FOO_SECOND
98 int
99 test_6 (enum foo f)
101 switch (f)
103 case FOO_FURST: /* { dg-error "10: .FOO_FURST. undeclared .first use in this function.; did you mean .FOO_FIRST." } */
104 break;
105 /* { dg-begin-multiline-output "" }
106 case FOO_FURST:
107 ^~~~~~~~~
108 FOO_FIRST
109 { dg-end-multiline-output "" } */
111 case FOO_SECCOND: /* { dg-error "10: .FOO_SECCOND. undeclared .first use in this function.; did you mean .FOO_SECOND." } */
112 break;
113 /* { dg-begin-multiline-output "" }
114 case FOO_SECCOND:
115 ^~~~~~~~~~~
116 FOO_SECOND
117 { dg-end-multiline-output "" } */
119 default:
120 break;
124 int snprintf (char *, __SIZE_TYPE__, const char *, ...);
126 void
127 test_7 (int i, int j)
129 int buffer[100];
130 snprint (buffer, 100, "%i of %i", i, j); /* { dg-warning "3: implicit declaration of function .snprint.; did you mean .snprintf.." } */
131 /* { dg-begin-multiline-output "" }
132 snprint (buffer, 100, "%i of %i", i, j);
133 ^~~~~~~
134 snprintf
135 { dg-end-multiline-output "" } */