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