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