err.c revision 1.14 1 1.14 lukem /* $NetBSD: err.c,v 1.14 2001/05/24 12:10:39 lukem Exp $ */
2 1.2 cgd
3 1.1 cgd /*
4 1.1 cgd * Copyright (c) 1994, 1995 Jochen Pohl
5 1.1 cgd * All Rights Reserved.
6 1.1 cgd *
7 1.1 cgd * Redistribution and use in source and binary forms, with or without
8 1.1 cgd * modification, are permitted provided that the following conditions
9 1.1 cgd * are met:
10 1.1 cgd * 1. Redistributions of source code must retain the above copyright
11 1.1 cgd * notice, this list of conditions and the following disclaimer.
12 1.1 cgd * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 cgd * notice, this list of conditions and the following disclaimer in the
14 1.1 cgd * documentation and/or other materials provided with the distribution.
15 1.1 cgd * 3. All advertising materials mentioning features or use of this software
16 1.1 cgd * must display the following acknowledgement:
17 1.1 cgd * This product includes software developed by Jochen Pohl for
18 1.1 cgd * The NetBSD Project.
19 1.1 cgd * 4. The name of the author may not be used to endorse or promote products
20 1.1 cgd * derived from this software without specific prior written permission.
21 1.1 cgd *
22 1.1 cgd * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 1.1 cgd * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 1.1 cgd * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 1.1 cgd * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 1.1 cgd * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 1.1 cgd * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 1.1 cgd * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 1.1 cgd * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 1.1 cgd * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 1.1 cgd * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 1.1 cgd */
33 1.1 cgd
34 1.10 christos #include <sys/cdefs.h>
35 1.1 cgd #ifndef lint
36 1.14 lukem __RCSID("$NetBSD: err.c,v 1.14 2001/05/24 12:10:39 lukem Exp $");
37 1.1 cgd #endif
38 1.1 cgd
39 1.12 christos #define FD_SETSIZE 512
40 1.12 christos #include <sys/types.h>
41 1.1 cgd #include <stdlib.h>
42 1.1 cgd #ifdef __STDC__
43 1.1 cgd #include <stdarg.h>
44 1.1 cgd #else
45 1.1 cgd #include <varargs.h>
46 1.1 cgd #endif
47 1.1 cgd
48 1.1 cgd #include "lint1.h"
49 1.1 cgd
50 1.12 christos /* number of errors found */
51 1.12 christos int nerr;
52 1.12 christos
53 1.12 christos /* number of syntax errors */
54 1.12 christos int sytxerr;
55 1.12 christos
56 1.12 christos extern fd_set msgset;
57 1.12 christos
58 1.12 christos
59 1.1 cgd static const char *basename __P((const char *));
60 1.3 jpo static void verror __P((int, va_list));
61 1.3 jpo static void vwarning __P((int, va_list));
62 1.3 jpo
63 1.1 cgd
64 1.1 cgd const char *msgs[] = {
65 1.1 cgd "syntax error: empty declaration", /* 0 */
66 1.1 cgd "old style declaration; add int", /* 1 */
67 1.1 cgd "empty declaration", /* 2 */
68 1.1 cgd "%s declared in argument declaration list", /* 3 */
69 1.1 cgd "illegal type combination", /* 4 */
70 1.1 cgd "modifying typedef with '%s'; only qualifiers allowed", /* 5 */
71 1.1 cgd "use 'double' instead of 'long float'", /* 6 */
72 1.1 cgd "only one storage class allowed", /* 7 */
73 1.1 cgd "illegal storage class", /* 8 */
74 1.1 cgd "only register valid as formal parameter storage class", /* 9 */
75 1.1 cgd "duplicate '%s'", /* 10 */
76 1.1 cgd "bit-field initializer out of range", /* 11 */
77 1.1 cgd "compiler takes size of function", /* 12 */
78 1.1 cgd "incomplete enum type: %s", /* 13 */
79 1.1 cgd "compiler takes alignment of function", /* 14 */
80 1.1 cgd "function returns illegal type", /* 15 */
81 1.1 cgd "array of function is illegal", /* 16 */
82 1.1 cgd "null dimension", /* 17 */
83 1.1 cgd "illegal use of 'void'", /* 18 */
84 1.1 cgd "void type for %s", /* 19 */
85 1.1 cgd "zero or negative array dimension", /* 20 */
86 1.1 cgd "redeclaration of formal parameter %s", /* 21 */
87 1.1 cgd "incomplete or misplaced function definition", /* 22 */
88 1.1 cgd "undefined label %s", /* 23 */
89 1.1 cgd "cannot initialize function: %s", /* 24 */
90 1.1 cgd "cannot initialize typedef: %s", /* 25 */
91 1.1 cgd "cannot initialize extern declaration: %s", /* 26 */
92 1.1 cgd "redeclaration of %s", /* 27 */
93 1.1 cgd "redefinition of %s", /* 28 */
94 1.1 cgd "previously declared extern, becomes static: %s", /* 29 */
95 1.1 cgd "redeclaration of %s; ANSI C requires static", /* 30 */
96 1.1 cgd "incomplete structure or union %s: %s", /* 31 */
97 1.1 cgd "argument type defaults to 'int': %s", /* 32 */
98 1.1 cgd "duplicate member name: %s", /* 33 */
99 1.1 cgd "nonportable bit-field type", /* 34 */
100 1.1 cgd "illegal bit-field type", /* 35 */
101 1.1 cgd "illegal bit-field size", /* 36 */
102 1.1 cgd "zero size bit-field", /* 37 */
103 1.1 cgd "function illegal in structure or union", /* 38 */
104 1.1 cgd "illegal zero sized structure member: %s", /* 39 */
105 1.1 cgd "unknown size: %s", /* 40 */
106 1.1 cgd "illegal use of bit-field", /* 41 */
107 1.1 cgd "forward reference to enum type", /* 42 */
108 1.1 cgd "redefinition hides earlier one: %s", /* 43 */
109 1.1 cgd "declaration introduces new type in ANSI C: %s %s", /* 44 */
110 1.1 cgd "base type is really '%s %s'", /* 45 */
111 1.1 cgd "(%s) tag redeclared", /* 46 */
112 1.1 cgd "zero sized %s", /* 47 */
113 1.1 cgd "overflow in enumeration values: %s", /* 48 */
114 1.1 cgd "struct or union member must be named", /* 49 */
115 1.1 cgd "a function is declared as an argument: %s", /* 50 */
116 1.1 cgd "parameter mismatch: %d declared, %d defined", /* 51 */
117 1.1 cgd "cannot initialize parameter: %s", /* 52 */
118 1.1 cgd "declared argument %s is missing", /* 53 */
119 1.1 cgd "trailing ',' prohibited in enum declaration", /* 54 */
120 1.1 cgd "integral constant expression expected", /* 55 */
121 1.1 cgd "integral constant too large", /* 56 */
122 1.1 cgd "enumeration constant hides parameter: %s", /* 57 */
123 1.1 cgd "type does not match prototype: %s", /* 58 */
124 1.1 cgd "formal parameter lacks name: param #%d", /* 59 */
125 1.1 cgd "void must be sole parameter", /* 60 */
126 1.1 cgd "void parameter cannot have name: %s", /* 61 */
127 1.1 cgd "function prototype parameters must have types", /* 62 */
128 1.1 cgd "prototype does not match old-style definition", /* 63 */
129 1.1 cgd "()-less function definition", /* 64 */
130 1.1 cgd "%s has no named members", /* 65 */
131 1.1 cgd "syntax requires ';' after last struct/union member", /* 66 */
132 1.1 cgd "cannot return incomplete type", /* 67 */
133 1.1 cgd "typedef already qualified with '%s'", /* 68 */
134 1.1 cgd "inappropriate qualifiers with 'void'", /* 69 */
135 1.1 cgd "%soperand of '%s' is unsigned in ANSI C", /* 70 */
136 1.1 cgd "too many characters in character constant", /* 71 */
137 1.1 cgd "typedef declares no type name", /* 72 */
138 1.1 cgd "empty character constant", /* 73 */
139 1.1 cgd "no hex digits follow \\x", /* 74 */
140 1.1 cgd "overflow in hex escape", /* 75 */
141 1.1 cgd "character escape does not fit in character", /* 76 */
142 1.1 cgd "bad octal digit %c", /* 77 */
143 1.1 cgd "nonportable character escape", /* 78 */
144 1.1 cgd "dubious escape \\%c", /* 79 */
145 1.1 cgd "dubious escape \\%o", /* 80 */
146 1.1 cgd "\\a undefined in traditional C", /* 81 */
147 1.1 cgd "\\x undefined in traditional C", /* 82 */
148 1.1 cgd "storage class after type is obsolescent", /* 83 */
149 1.1 cgd "ANSI C requires formal parameter before '...'", /* 84 */
150 1.1 cgd "dubious tag declaration: %s %s", /* 85 */
151 1.1 cgd "automatic hides external declaration: %s", /* 86 */
152 1.1 cgd "static hides external declaration: %s", /* 87 */
153 1.1 cgd "typedef hides external declaration: %s", /* 88 */
154 1.1 cgd "typedef redeclared: %s", /* 89 */
155 1.1 cgd "inconsistent redeclaration of extern: %s", /* 90 */
156 1.1 cgd "declaration hides parameter: %s", /* 91 */
157 1.1 cgd "inconsistent redeclaration of static: %s", /* 92 */
158 1.1 cgd "dubious static function at block level: %s", /* 93 */
159 1.1 cgd "function has illegal storage class: %s", /* 94 */
160 1.1 cgd "declaration hides earlier one: %s", /* 95 */
161 1.1 cgd "cannot dereference non-pointer type", /* 96 */
162 1.1 cgd "suffix U is illegal in traditional C", /* 97 */
163 1.1 cgd "suffixes F and L are illegal in traditional C", /* 98 */
164 1.1 cgd "%s undefined", /* 99 */
165 1.1 cgd "unary + is illegal in traditional C", /* 100 */
166 1.1 cgd "undefined struct/union member: %s", /* 101 */
167 1.1 cgd "illegal member use: %s", /* 102 */
168 1.1 cgd "left operand of '.' must be struct/union object", /* 103 */
169 1.1 cgd "left operand of '->' must be pointer to struct/union", /* 104 */
170 1.1 cgd "non-unique member requires struct/union %s", /* 105 */
171 1.1 cgd "left operand of '->' must be pointer", /* 106 */
172 1.1 cgd "operands of '%s' have incompatible types", /* 107 */
173 1.1 cgd "operand of '%s' has incompatible type", /* 108 */
174 1.1 cgd "void type illegal in expression", /* 109 */
175 1.1 cgd "pointer to function is not allowed here", /* 110 */
176 1.1 cgd "unacceptable operand of '%s'", /* 111 */
177 1.1 cgd "cannot take address of bit-field", /* 112 */
178 1.1 cgd "cannot take address of register %s", /* 113 */
179 1.1 cgd "%soperand of '%s' must be lvalue", /* 114 */
180 1.1 cgd "%soperand of '%s' must be modifiable lvalue", /* 115 */
181 1.1 cgd "illegal pointer subtraction", /* 116 */
182 1.1 cgd "bitwise operation on signed value possibly nonportable", /* 117 */
183 1.1 cgd "semantics of '%s' change in ANSI C; use explicit cast", /* 118 */
184 1.1 cgd "conversion of '%s' to '%s' is out of range", /* 119 */
185 1.1 cgd "bitwise operation on signed value nonportable", /* 120 */
186 1.1 cgd "negative shift", /* 121 */
187 1.1 cgd "shift greater than size of object", /* 122 */
188 1.1 cgd "illegal combination of pointer and integer, op %s", /* 123 */
189 1.1 cgd "illegal pointer combination, op %s", /* 124 */
190 1.1 cgd "ANSI C forbids ordered comparisons of pointers to functions",/* 125 */
191 1.1 cgd "incompatible types in conditional", /* 126 */
192 1.1 cgd "'&' before array or function: ignored", /* 127 */
193 1.1 cgd "operands have incompatible pointer types, op %s", /* 128 */
194 1.1 cgd "expression has null effect", /* 129 */
195 1.1 cgd "enum type mismatch, op %s", /* 130 */
196 1.1 cgd "conversion to '%s' may sign-extend incorrectly", /* 131 */
197 1.1 cgd "conversion from '%s' may lose accuracy", /* 132 */
198 1.1 cgd "conversion of pointer to '%s' loses bits", /* 133 */
199 1.1 cgd "conversion of pointer to '%s' may lose bits", /* 134 */
200 1.1 cgd "possible pointer alignment problem", /* 135 */
201 1.1 cgd "cannot do pointer arithmetic on operand of unknown size", /* 136 */
202 1.1 cgd "use of incomplete enum type, op %s", /* 137 */
203 1.1 cgd "unknown operand size, op %s", /* 138 */
204 1.1 cgd "division by 0", /* 139 */
205 1.1 cgd "modulus by 0", /* 140 */
206 1.1 cgd "integer overflow detected, op %s", /* 141 */
207 1.1 cgd "floating point overflow detected, op %s", /* 142 */
208 1.1 cgd "cannot take size of incomplete type", /* 143 */
209 1.1 cgd "cannot take size of function", /* 144 */
210 1.1 cgd "cannot take size of bit-field", /* 145 */
211 1.1 cgd "cannot take size of void", /* 146 */
212 1.1 cgd "invalid cast expression", /* 147 */
213 1.1 cgd "improper cast of void expression", /* 148 */
214 1.1 cgd "illegal function", /* 149 */
215 1.1 cgd "argument mismatch: %d arg%s passed, %d expected", /* 150 */
216 1.1 cgd "void expressions may not be arguments, arg #%d", /* 151 */
217 1.1 cgd "argument cannot have unknown size, arg #%d", /* 152 */
218 1.1 cgd "argument has incompatible pointer type, arg #%d", /* 153 */
219 1.1 cgd "illegal combination of pointer and integer, arg #%d", /* 154 */
220 1.1 cgd "argument is incompatible with prototype, arg #%d", /* 155 */
221 1.1 cgd "enum type mismatch, arg #%d", /* 156 */
222 1.1 cgd "ANSI C treats constant as unsigned", /* 157 */
223 1.1 cgd "%s may be used before set", /* 158 */
224 1.1 cgd "assignment in conditional context", /* 159 */
225 1.1 cgd "operator '==' found where '=' was expected", /* 160 */
226 1.1 cgd "constant in conditional context", /* 161 */
227 1.11 mycroft "comparison of %s with %s, op %s", /* 162 */
228 1.1 cgd "a cast does not yield an lvalue", /* 163 */
229 1.1 cgd "assignment of negative constant to unsigned type", /* 164 */
230 1.1 cgd "constant truncated by assignment", /* 165 */
231 1.1 cgd "precision lost in bit-field assignment", /* 166 */
232 1.1 cgd "array subscript cannot be negative: %ld", /* 167 */
233 1.1 cgd "array subscript cannot be > %d: %ld", /* 168 */
234 1.1 cgd "precedence confusion possible: parenthesize!", /* 169 */
235 1.1 cgd "first operand must have scalar type, op ? :", /* 170 */
236 1.1 cgd "assignment type mismatch", /* 171 */
237 1.1 cgd "too many struct/union initializers", /* 172 */
238 1.1 cgd "too many array initializers", /* 173 */
239 1.1 cgd "too many initializers", /* 174 */
240 1.1 cgd "initialisation of an incomplete type", /* 175 */
241 1.1 cgd "invalid initializer", /* 176 */
242 1.1 cgd "non-constant initializer", /* 177 */
243 1.1 cgd "initializer does not fit", /* 178 */
244 1.1 cgd "cannot initialize struct/union with no named member", /* 179 */
245 1.1 cgd "bit-field initializer does not fit", /* 180 */
246 1.1 cgd "{}-enclosed initializer required", /* 181 */
247 1.1 cgd "incompatible pointer types", /* 182 */
248 1.1 cgd "illegal combination of pointer and integer", /* 183 */
249 1.1 cgd "illegal pointer combination", /* 184 */
250 1.1 cgd "initialisation type mismatch", /* 185 */
251 1.1 cgd "bit-field initialisation is illegal in traditional C", /* 186 */
252 1.1 cgd "non-null byte ignored in string initializer", /* 187 */
253 1.1 cgd "no automatic aggregate initialization in traditional C", /* 188 */
254 1.1 cgd "assignment of struct/union illegal in traditional C", /* 189 */
255 1.1 cgd "empty array declaration: %s", /* 190 */
256 1.1 cgd "%s set but not used in function %s", /* 191 */
257 1.1 cgd "%s unused in function %s", /* 192 */
258 1.1 cgd "statement not reached", /* 193 */
259 1.1 cgd "label %s redefined", /* 194 */
260 1.1 cgd "case not in switch", /* 195 */
261 1.1 cgd "case label affected by conversion", /* 196 */
262 1.1 cgd "non-constant case expression", /* 197 */
263 1.1 cgd "non-integral case expression", /* 198 */
264 1.1 cgd "duplicate case in switch: %ld", /* 199 */
265 1.1 cgd "duplicate case in switch: %lu", /* 200 */
266 1.1 cgd "default outside switch", /* 201 */
267 1.1 cgd "duplicate default in switch", /* 202 */
268 1.1 cgd "case label must be of type `int' in traditional C", /* 203 */
269 1.1 cgd "controlling expressions must have scalar type", /* 204 */
270 1.1 cgd "switch expression must have integral type", /* 205 */
271 1.1 cgd "enumeration value(s) not handled in switch", /* 206 */
272 1.1 cgd "loop not entered at top", /* 207 */
273 1.1 cgd "break outside loop or switch", /* 208 */
274 1.1 cgd "continue outside loop", /* 209 */
275 1.1 cgd "enum type mismatch in initialisation", /* 210 */
276 1.1 cgd "return value type mismatch", /* 211 */
277 1.1 cgd "cannot return incomplete type", /* 212 */
278 1.1 cgd "void function %s cannot return value", /* 213 */
279 1.1 cgd "function %s expects to return value", /* 214 */
280 1.1 cgd "function implicitly declared to return int", /* 215 */
281 1.1 cgd "function %s has return (e); and return;", /* 216 */
282 1.1 cgd "function %s falls off bottom without returning value", /* 217 */
283 1.1 cgd "ANSI C treats constant as unsigned, op %s", /* 218 */
284 1.1 cgd "concatenated strings are illegal in traditional C", /* 219 */
285 1.1 cgd "fallthrough on case statement", /* 220 */
286 1.1 cgd "initialisation of unsigned with negative constant", /* 221 */
287 1.1 cgd "conversion of negative constant to unsigned type", /* 222 */
288 1.1 cgd "end-of-loop code not reached", /* 223 */
289 1.1 cgd "cannot recover from previous errors", /* 224 */
290 1.1 cgd "static function called but not defined: %s()", /* 225 */
291 1.1 cgd "static variable %s unused", /* 226 */
292 1.1 cgd "const object %s should have initializer", /* 227 */
293 1.1 cgd "function cannot return const or volatile object", /* 228 */
294 1.1 cgd "questionable conversion of function pointer", /* 229 */
295 1.11 mycroft "nonportable character comparison, op %s", /* 230 */
296 1.1 cgd "argument %s unused in function %s", /* 231 */
297 1.1 cgd "label %s unused in function %s", /* 232 */
298 1.1 cgd "struct %s never defined", /* 233 */
299 1.1 cgd "union %s never defined", /* 234 */
300 1.1 cgd "enum %s never defined", /* 235 */
301 1.1 cgd "static function %s unused", /* 236 */
302 1.1 cgd "redeclaration of formal parameter %s", /* 237 */
303 1.1 cgd "initialisation of union is illegal in traditional C", /* 238 */
304 1.1 cgd "constant argument to NOT", /* 239 */
305 1.1 cgd "assignment of different structures", /* 240 */
306 1.1 cgd "dubious operation on enum, op %s", /* 241 */
307 1.1 cgd "combination of '%s' and '%s', op %s", /* 242 */
308 1.11 mycroft "dubious comparison of enums, op %s", /* 243 */
309 1.1 cgd "illegal structure pointer combination", /* 244 */
310 1.1 cgd "illegal structure pointer combination, op %s", /* 245 */
311 1.1 cgd "dubious conversion of enum to '%s'", /* 246 */
312 1.1 cgd "pointer casts may be troublesome", /* 247 */
313 1.1 cgd "floating-point constant out of range", /* 248 */
314 1.1 cgd "syntax error", /* 249 */
315 1.1 cgd "unknown character \\%o", /* 250 */
316 1.1 cgd "malformed integer constant", /* 251 */
317 1.1 cgd "integer constant out of range", /* 252 */
318 1.1 cgd "unterminated character constant", /* 253 */
319 1.1 cgd "newline in string or char constant", /* 254 */
320 1.1 cgd "undefined or invalid # directive", /* 255 */
321 1.1 cgd "unterminated comment", /* 256 */
322 1.1 cgd "extra characters in lint comment", /* 257 */
323 1.1 cgd "unterminated string constant", /* 258 */
324 1.1 cgd "conversion to '%s' due to prototype, arg #%d", /* 259 */
325 1.1 cgd "previous declaration of %s", /* 260 */
326 1.1 cgd "previous definition of %s", /* 261 */
327 1.1 cgd "\\\" inside character constants undefined in traditional C", /* 262 */
328 1.1 cgd "\\? undefined in traditional C", /* 263 */
329 1.1 cgd "\\v undefined in traditional C", /* 264 */
330 1.5 jpo "%s C does not support 'long long'", /* 265 */
331 1.1 cgd "'long double' is illegal in traditional C", /* 266 */
332 1.1 cgd "shift equal to size of object", /* 267 */
333 1.4 jpo "variable declared inline: %s", /* 268 */
334 1.4 jpo "argument declared inline: %s", /* 269 */
335 1.1 cgd "function prototypes are illegal in traditional C", /* 270 */
336 1.1 cgd "switch expression must be of type `int' in traditional C", /* 271 */
337 1.1 cgd "empty translation unit", /* 272 */
338 1.1 cgd "bit-field type '%s' invalid in ANSI C", /* 273 */
339 1.11 mycroft "ANSI C forbids comparison of %s with %s", /* 274 */
340 1.6 jpo "cast discards 'const' from pointer target type", /* 275 */
341 1.1 cgd "", /* 276 */
342 1.1 cgd "initialisation of '%s' with '%s'", /* 277 */
343 1.1 cgd "combination of '%s' and '%s', arg #%d", /* 278 */
344 1.1 cgd "combination of '%s' and '%s' in return", /* 279 */
345 1.1 cgd "must be outside function: /* %s */", /* 280 */
346 1.1 cgd "duplicate use of /* %s */", /* 281 */
347 1.1 cgd "must precede function definition: /* %s */", /* 282 */
348 1.1 cgd "argument number mismatch with directive: /* %s */", /* 283 */
349 1.1 cgd "fallthrough on default statement", /* 284 */
350 1.1 cgd "prototype declaration", /* 285 */
351 1.1 cgd "function definition is not a prototype", /* 286 */
352 1.1 cgd "function declaration is not a prototype", /* 287 */
353 1.1 cgd "dubious use of /* VARARGS */ with /* %s */", /* 288 */
354 1.1 cgd "can't be used together: /* PRINTFLIKE */ /* SCANFLIKE */", /* 289 */
355 1.1 cgd "static function %s declared but not defined", /* 290 */
356 1.1 cgd "invalid multibyte character", /* 291 */
357 1.1 cgd "cannot concatenate wide and regular string literals", /* 292 */
358 1.1 cgd "argument %d must be 'char *' for PRINTFLIKE/SCANFLIKE", /* 293 */
359 1.1 cgd "multi-character character constant", /* 294 */
360 1.1 cgd "conversion of '%s' to '%s' is out of range, arg #%d", /* 295 */
361 1.1 cgd "conversion of negative constant to unsigned type, arg #%d", /* 296 */
362 1.1 cgd "conversion to '%s' may sign-extend incorrectly, arg #%d", /* 297 */
363 1.1 cgd "conversion from '%s' may lose accuracy, arg #%d", /* 298 */
364 1.1 cgd "prototype does not match old style definition, arg #%d", /* 299 */
365 1.1 cgd "old style definition", /* 300 */
366 1.1 cgd "array of incomplete type", /* 301 */
367 1.1 cgd "%s returns pointer to automatic object", /* 302 */
368 1.1 cgd "ANSI C forbids conversion of %s to %s", /* 303 */
369 1.1 cgd "ANSI C forbids conversion of %s to %s, arg #%d", /* 304 */
370 1.1 cgd "ANSI C forbids conversion of %s to %s, op %s", /* 305 */
371 1.1 cgd "constant truncated by conversion, op %s", /* 306 */
372 1.1 cgd "static variable %s set but not used", /* 307 */
373 1.8 jpo "", /* 308 */
374 1.1 cgd "extra bits set to 0 in conversion of '%s' to '%s', op %s", /* 309 */
375 1.9 cgd "symbol renaming can't be used on function arguments", /* 310 */
376 1.9 cgd "symbol renaming can't be used on automatic variables", /* 311 */
377 1.14 lukem "%s C does not support // comments", /* 312 */
378 1.1 cgd };
379 1.1 cgd
380 1.1 cgd /*
381 1.12 christos * print a list of the messages with their ids
382 1.12 christos */
383 1.12 christos void
384 1.12 christos msglist()
385 1.12 christos {
386 1.12 christos int i;
387 1.12 christos
388 1.12 christos for (i = 0; i < sizeof(msgs) / sizeof(msgs[0]); i++)
389 1.12 christos printf("%d\t%s\n", i, msgs[i]);
390 1.12 christos }
391 1.12 christos
392 1.12 christos /*
393 1.1 cgd * If Fflag is not set basename() returns a pointer to the last
394 1.1 cgd * component of the path, otherwise it returns the argument.
395 1.1 cgd */
396 1.1 cgd static const char *
397 1.1 cgd basename(path)
398 1.1 cgd const char *path;
399 1.1 cgd {
400 1.1 cgd const char *cp, *cp1, *cp2;
401 1.1 cgd
402 1.1 cgd if (Fflag)
403 1.1 cgd return (path);
404 1.1 cgd
405 1.1 cgd cp = cp1 = cp2 = path;
406 1.1 cgd while (*cp != '\0') {
407 1.1 cgd if (*cp++ == '/') {
408 1.1 cgd cp2 = cp1;
409 1.1 cgd cp1 = cp;
410 1.1 cgd }
411 1.1 cgd }
412 1.1 cgd return (*cp1 == '\0' ? cp2 : cp1);
413 1.1 cgd }
414 1.1 cgd
415 1.3 jpo static void
416 1.3 jpo verror(n, ap)
417 1.3 jpo int n;
418 1.3 jpo va_list ap;
419 1.3 jpo {
420 1.3 jpo const char *fn;
421 1.3 jpo
422 1.12 christos if (FD_ISSET(n, &msgset))
423 1.12 christos return;
424 1.12 christos
425 1.3 jpo fn = basename(curr_pos.p_file);
426 1.3 jpo (void)printf("%s(%d): ", fn, curr_pos.p_line);
427 1.3 jpo (void)vprintf(msgs[n], ap);
428 1.12 christos (void)printf(" [%d]\n", n);
429 1.3 jpo nerr++;
430 1.3 jpo }
431 1.3 jpo
432 1.3 jpo static void
433 1.3 jpo vwarning(n, ap)
434 1.3 jpo int n;
435 1.3 jpo va_list ap;
436 1.3 jpo {
437 1.3 jpo const char *fn;
438 1.3 jpo
439 1.12 christos if (FD_ISSET(n, &msgset))
440 1.12 christos return;
441 1.12 christos
442 1.7 jpo if (nowarn)
443 1.3 jpo /* this warning is suppressed by a LINTED comment */
444 1.3 jpo return;
445 1.3 jpo
446 1.3 jpo fn = basename(curr_pos.p_file);
447 1.3 jpo (void)printf("%s(%d): warning: ", fn, curr_pos.p_line);
448 1.3 jpo (void)vprintf(msgs[n], ap);
449 1.12 christos (void)printf(" [%d]\n", n);
450 1.12 christos if (wflag)
451 1.12 christos nerr++;
452 1.3 jpo }
453 1.3 jpo
454 1.3 jpo void
455 1.1 cgd #ifdef __STDC__
456 1.1 cgd error(int n, ...)
457 1.1 cgd #else
458 1.3 jpo error(n, va_alist)
459 1.3 jpo int n;
460 1.1 cgd va_dcl
461 1.3 jpo #endif
462 1.1 cgd {
463 1.1 cgd va_list ap;
464 1.1 cgd
465 1.1 cgd #ifdef __STDC__
466 1.1 cgd va_start(ap, n);
467 1.1 cgd #else
468 1.1 cgd va_start(ap);
469 1.1 cgd #endif
470 1.3 jpo verror(n, ap);
471 1.1 cgd va_end(ap);
472 1.1 cgd }
473 1.1 cgd
474 1.3 jpo void
475 1.1 cgd #ifdef __STDC__
476 1.1 cgd lerror(const char *msg, ...)
477 1.1 cgd #else
478 1.3 jpo lerror(msg, va_alist)
479 1.3 jpo const char *msg;
480 1.1 cgd va_dcl
481 1.3 jpo #endif
482 1.1 cgd {
483 1.1 cgd va_list ap;
484 1.1 cgd const char *fn;
485 1.1 cgd
486 1.1 cgd #ifdef __STDC__
487 1.1 cgd va_start(ap, msg);
488 1.1 cgd #else
489 1.1 cgd va_start(ap);
490 1.1 cgd #endif
491 1.1 cgd fn = basename(curr_pos.p_file);
492 1.1 cgd (void)fprintf(stderr, "%s(%d): lint error: ", fn, curr_pos.p_line);
493 1.1 cgd (void)vfprintf(stderr, msg, ap);
494 1.1 cgd (void)fprintf(stderr, "\n");
495 1.1 cgd va_end(ap);
496 1.1 cgd exit(1);
497 1.1 cgd }
498 1.1 cgd
499 1.3 jpo void
500 1.1 cgd #ifdef __STDC__
501 1.1 cgd warning(int n, ...)
502 1.3 jpo #else
503 1.3 jpo warning(n, va_alist)
504 1.3 jpo int n;
505 1.3 jpo va_dcl
506 1.3 jpo #endif
507 1.1 cgd {
508 1.3 jpo va_list ap;
509 1.3 jpo
510 1.3 jpo #ifdef __STDC__
511 1.3 jpo va_start(ap, n);
512 1.1 cgd #else
513 1.3 jpo va_start(ap);
514 1.3 jpo #endif
515 1.3 jpo vwarning(n, ap);
516 1.3 jpo va_end(ap);
517 1.3 jpo }
518 1.3 jpo
519 1.1 cgd void
520 1.3 jpo #ifdef __STDC__
521 1.3 jpo message(int n, ...)
522 1.3 jpo #else
523 1.3 jpo message(n, va_alist)
524 1.3 jpo int n;
525 1.1 cgd va_dcl
526 1.3 jpo #endif
527 1.1 cgd {
528 1.1 cgd va_list ap;
529 1.1 cgd const char *fn;
530 1.1 cgd
531 1.12 christos if (FD_ISSET(n, &msgset))
532 1.12 christos return;
533 1.12 christos
534 1.1 cgd #ifdef __STDC__
535 1.1 cgd va_start(ap, n);
536 1.1 cgd #else
537 1.1 cgd va_start(ap);
538 1.1 cgd #endif
539 1.1 cgd fn = basename(curr_pos.p_file);
540 1.3 jpo (void)printf("%s(%d): ", fn, curr_pos.p_line);
541 1.1 cgd (void)vprintf(msgs[n], ap);
542 1.12 christos (void)printf(" [%d]\n", n);
543 1.1 cgd va_end(ap);
544 1.1 cgd }
545 1.1 cgd
546 1.5 jpo int
547 1.1 cgd #ifdef __STDC__
548 1.3 jpo gnuism(int n, ...)
549 1.1 cgd #else
550 1.3 jpo gnuism(n, va_alist)
551 1.3 jpo int n;
552 1.1 cgd va_dcl
553 1.3 jpo #endif
554 1.1 cgd {
555 1.1 cgd va_list ap;
556 1.5 jpo int msg;
557 1.1 cgd
558 1.1 cgd #ifdef __STDC__
559 1.1 cgd va_start(ap, n);
560 1.1 cgd #else
561 1.1 cgd va_start(ap);
562 1.1 cgd #endif
563 1.3 jpo if (sflag && !gflag) {
564 1.3 jpo verror(n, ap);
565 1.5 jpo msg = 1;
566 1.5 jpo } else if (!sflag && gflag) {
567 1.5 jpo msg = 0;
568 1.5 jpo } else {
569 1.3 jpo vwarning(n, ap);
570 1.5 jpo msg = 1;
571 1.3 jpo }
572 1.1 cgd va_end(ap);
573 1.5 jpo
574 1.5 jpo return (msg);
575 1.1 cgd }
576