1281168Spfg/*	$NetBSD: err.c,v 1.40 2009/04/15 01:20:57 christos Exp $	*/
212099Sjoerg
312099Sjoerg/*
412099Sjoerg * Copyright (c) 1994, 1995 Jochen Pohl
512099Sjoerg * All Rights Reserved.
612099Sjoerg *
712099Sjoerg * Redistribution and use in source and binary forms, with or without
812099Sjoerg * modification, are permitted provided that the following conditions
912099Sjoerg * are met:
1012099Sjoerg * 1. Redistributions of source code must retain the above copyright
1112099Sjoerg *    notice, this list of conditions and the following disclaimer.
1212099Sjoerg * 2. Redistributions in binary form must reproduce the above copyright
1312099Sjoerg *    notice, this list of conditions and the following disclaimer in the
1412099Sjoerg *    documentation and/or other materials provided with the distribution.
1512099Sjoerg * 3. All advertising materials mentioning features or use of this software
1612099Sjoerg *    must display the following acknowledgement:
1712099Sjoerg *      This product includes software developed by Jochen Pohl for
1812099Sjoerg *	The NetBSD Project.
1912099Sjoerg * 4. The name of the author may not be used to endorse or promote products
2012099Sjoerg *    derived from this software without specific prior written permission.
2112099Sjoerg *
2212099Sjoerg * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
2312099Sjoerg * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
2412099Sjoerg * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
2512099Sjoerg * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
2612099Sjoerg * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2712099Sjoerg * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2812099Sjoerg * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2912099Sjoerg * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3012099Sjoerg * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
3112099Sjoerg * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3212099Sjoerg */
3312099Sjoerg
3491592Smarkm#include <sys/cdefs.h>
3591592Smarkm#if defined(__RCSID) && !defined(lint)
36281168Spfg__RCSID("$NetBSD: err.c,v 1.40 2009/04/15 01:20:57 christos Exp $");
3712099Sjoerg#endif
3891592Smarkm__FBSDID("$FreeBSD$");
3912099Sjoerg
4091592Smarkm#include <sys/types.h>
4191592Smarkm#include <stdlib.h>
4291592Smarkm#include <stdarg.h>
4391592Smarkm
4491592Smarkm#include "lint1.h"
4591592Smarkm
4612099Sjoerg/* number of errors found */
4712099Sjoergint	nerr;
4812099Sjoerg
4912099Sjoerg/* number of syntax errors */
5012099Sjoergint	sytxerr;
5112099Sjoerg
5212099Sjoerg
53100364Smarkmstatic	const	char *lbasename(const char *);
5491592Smarkmstatic	void	verror(int, va_list);
5591592Smarkmstatic	void	vwarning(int, va_list);
5612099Sjoerg
5712099Sjoerg
5812099Sjoergconst	char *msgs[] = {
5912099Sjoerg	"syntax error: empty declaration",			      /* 0 */
6012099Sjoerg	"old style declaration; add int",			      /* 1 */
6112099Sjoerg	"empty declaration",					      /* 2 */
6212099Sjoerg	"%s declared in argument declaration list",		      /* 3 */
6312099Sjoerg	"illegal type combination",				      /* 4 */
6412099Sjoerg	"modifying typedef with '%s'; only qualifiers allowed",	      /* 5 */
6512099Sjoerg	"use 'double' instead of 'long float'",			      /* 6 */
6612099Sjoerg	"only one storage class allowed",			      /* 7 */
6712099Sjoerg	"illegal storage class",				      /* 8 */
6812099Sjoerg	"only register valid as formal parameter storage class",      /* 9 */
6912099Sjoerg	"duplicate '%s'",					      /* 10 */
7012099Sjoerg	"bit-field initializer out of range",			      /* 11 */
7112099Sjoerg	"compiler takes size of function",			      /* 12 */
7212099Sjoerg	"incomplete enum type: %s",				      /* 13 */
7312099Sjoerg	"compiler takes alignment of function",			      /* 14 */
7412099Sjoerg	"function returns illegal type",			      /* 15 */
7512099Sjoerg	"array of function is illegal",				      /* 16 */
7612099Sjoerg	"null dimension",					      /* 17 */
7712099Sjoerg	"illegal use of 'void'",				      /* 18 */
7812099Sjoerg	"void type for %s",					      /* 19 */
79281168Spfg	"negative array dimension (%d)",			      /* 20 */
8012099Sjoerg	"redeclaration of formal parameter %s",			      /* 21 */
8112099Sjoerg	"incomplete or misplaced function definition",		      /* 22 */
8212099Sjoerg	"undefined label %s",					      /* 23 */
8312099Sjoerg	"cannot initialize function: %s",			      /* 24 */
8412099Sjoerg	"cannot initialize typedef: %s",			      /* 25 */
8512099Sjoerg	"cannot initialize extern declaration: %s",		      /* 26 */
8612099Sjoerg	"redeclaration of %s",					      /* 27 */
8712099Sjoerg	"redefinition of %s",					      /* 28 */
8812099Sjoerg	"previously declared extern, becomes static: %s",	      /* 29 */
8912099Sjoerg	"redeclaration of %s; ANSI C requires static",		      /* 30 */
9012099Sjoerg	"incomplete structure or union %s: %s",			      /* 31 */
9112099Sjoerg	"argument type defaults to 'int': %s",			      /* 32 */
9212099Sjoerg	"duplicate member name: %s",				      /* 33 */
9312099Sjoerg	"nonportable bit-field type",				      /* 34 */
9412099Sjoerg	"illegal bit-field type",				      /* 35 */
9512099Sjoerg	"illegal bit-field size",				      /* 36 */
9612099Sjoerg	"zero size bit-field",					      /* 37 */
9712099Sjoerg	"function illegal in structure or union",		      /* 38 */
98281168Spfg	"zero sized array in struct is a C99 extension: %s",	      /* 39 */
9912099Sjoerg	"unknown size: %s",					      /* 40 */
10012099Sjoerg	"illegal use of bit-field",				      /* 41 */
10112099Sjoerg	"forward reference to enum type",			      /* 42 */
10212099Sjoerg	"redefinition hides earlier one: %s",			      /* 43 */
10312099Sjoerg	"declaration introduces new type in ANSI C: %s %s",	      /* 44 */
10412099Sjoerg	"base type is really '%s %s'",				      /* 45 */
10512099Sjoerg	"(%s) tag redeclared",					      /* 46 */
106281168Spfg	"zero sized %s is a C9X feature",			      /* 47 */
10712099Sjoerg	"overflow in enumeration values: %s",			      /* 48 */
10812099Sjoerg	"struct or union member must be named",			      /* 49 */
10912099Sjoerg	"a function is declared as an argument: %s",		      /* 50 */
11012099Sjoerg	"parameter mismatch: %d declared, %d defined",		      /* 51 */
11112099Sjoerg	"cannot initialize parameter: %s",			      /* 52 */
11212099Sjoerg	"declared argument %s is missing",			      /* 53 */
11312099Sjoerg	"trailing ',' prohibited in enum declaration",		      /* 54 */
11412099Sjoerg	"integral constant expression expected",		      /* 55 */
11512099Sjoerg	"integral constant too large",				      /* 56 */
11612099Sjoerg	"enumeration constant hides parameter: %s",		      /* 57 */
11712099Sjoerg	"type does not match prototype: %s",			      /* 58 */
11812099Sjoerg	"formal parameter lacks name: param #%d",		      /* 59 */
11912099Sjoerg	"void must be sole parameter",				      /* 60 */
12012099Sjoerg	"void parameter cannot have name: %s",			      /* 61 */
12112099Sjoerg	"function prototype parameters must have types",	      /* 62 */
12212099Sjoerg	"prototype does not match old-style definition",	      /* 63 */
12312099Sjoerg	"()-less function definition",				      /* 64 */
12412099Sjoerg	"%s has no named members",				      /* 65 */
12512099Sjoerg	"syntax requires ';' after last struct/union member",	      /* 66 */
12612099Sjoerg	"cannot return incomplete type",			      /* 67 */
12712099Sjoerg	"typedef already qualified with '%s'",			      /* 68 */
12812099Sjoerg	"inappropriate qualifiers with 'void'",			      /* 69 */
12912099Sjoerg	"%soperand of '%s' is unsigned in ANSI C",		      /* 70 */
13012099Sjoerg	"too many characters in character constant",		      /* 71 */
13112099Sjoerg	"typedef declares no type name",			      /* 72 */
13212099Sjoerg	"empty character constant",				      /* 73 */
13312099Sjoerg	"no hex digits follow \\x",				      /* 74 */
13412099Sjoerg	"overflow in hex escape",				      /* 75 */
13512099Sjoerg	"character escape does not fit in character",		      /* 76 */
13612099Sjoerg	"bad octal digit %c",					      /* 77 */
13712099Sjoerg	"nonportable character escape",				      /* 78 */
13812099Sjoerg	"dubious escape \\%c",					      /* 79 */
13912099Sjoerg	"dubious escape \\%o",					      /* 80 */
14012099Sjoerg	"\\a undefined in traditional C",			      /* 81 */
14112099Sjoerg	"\\x undefined in traditional C",			      /* 82 */
14212099Sjoerg	"storage class after type is obsolescent",		      /* 83 */
14312099Sjoerg	"ANSI C requires formal parameter before '...'",	      /* 84 */
14412099Sjoerg	"dubious tag declaration: %s %s",			      /* 85 */
14512099Sjoerg	"automatic hides external declaration: %s",		      /* 86 */
14612099Sjoerg	"static hides external declaration: %s",		      /* 87 */
14712099Sjoerg	"typedef hides external declaration: %s",		      /* 88 */
14812099Sjoerg	"typedef redeclared: %s",				      /* 89 */
14912099Sjoerg	"inconsistent redeclaration of extern: %s",		      /* 90 */
15012099Sjoerg	"declaration hides parameter: %s",			      /* 91 */
15112099Sjoerg	"inconsistent redeclaration of static: %s",		      /* 92 */
15212099Sjoerg	"dubious static function at block level: %s",		      /* 93 */
15312099Sjoerg	"function has illegal storage class: %s",		      /* 94 */
15412099Sjoerg	"declaration hides earlier one: %s",			      /* 95 */
15512099Sjoerg	"cannot dereference non-pointer type",			      /* 96 */
15612099Sjoerg	"suffix U is illegal in traditional C",			      /* 97 */
15712099Sjoerg	"suffixes F and L are illegal in traditional C",	      /* 98 */
15812099Sjoerg	"%s undefined",						      /* 99 */
15912099Sjoerg	"unary + is illegal in traditional C",			      /* 100 */
16012099Sjoerg	"undefined struct/union member: %s",			      /* 101 */
16112099Sjoerg	"illegal member use: %s",				      /* 102 */
16212099Sjoerg	"left operand of '.' must be struct/union object",	      /* 103 */
16312099Sjoerg	"left operand of '->' must be pointer to struct/union",	      /* 104 */
16412099Sjoerg	"non-unique member requires struct/union %s",		      /* 105 */
16512099Sjoerg	"left operand of '->' must be pointer",			      /* 106 */
16612099Sjoerg	"operands of '%s' have incompatible types",		      /* 107 */
16712099Sjoerg	"operand of '%s' has incompatible type",		      /* 108 */
16812099Sjoerg	"void type illegal in expression",			      /* 109 */
16912099Sjoerg	"pointer to function is not allowed here",		      /* 110 */
17012099Sjoerg	"unacceptable operand of '%s'",				      /* 111 */
17112099Sjoerg	"cannot take address of bit-field",			      /* 112 */
17212099Sjoerg	"cannot take address of register %s",			      /* 113 */
17312099Sjoerg	"%soperand of '%s' must be lvalue",			      /* 114 */
17412099Sjoerg	"%soperand of '%s' must be modifiable lvalue",		      /* 115 */
17512099Sjoerg	"illegal pointer subtraction",				      /* 116 */
17612099Sjoerg	"bitwise operation on signed value possibly nonportable",     /* 117 */
17712099Sjoerg	"semantics of '%s' change in ANSI C; use explicit cast",      /* 118 */
17812099Sjoerg	"conversion of '%s' to '%s' is out of range",		      /* 119 */
17912099Sjoerg	"bitwise operation on signed value nonportable",	      /* 120 */
18012099Sjoerg	"negative shift",					      /* 121 */
18112099Sjoerg	"shift greater than size of object",			      /* 122 */
18212099Sjoerg	"illegal combination of pointer and integer, op %s",	      /* 123 */
18312099Sjoerg	"illegal pointer combination, op %s",			      /* 124 */
18412099Sjoerg	"ANSI C forbids ordered comparisons of pointers to functions",/* 125 */
18512099Sjoerg	"incompatible types in conditional",			      /* 126 */
18612099Sjoerg	"'&' before array or function: ignored",		      /* 127 */
18712099Sjoerg	"operands have incompatible pointer types, op %s",	      /* 128 */
18812099Sjoerg	"expression has null effect",				      /* 129 */
18912099Sjoerg	"enum type mismatch, op %s",				      /* 130 */
19012099Sjoerg	"conversion to '%s' may sign-extend incorrectly",	      /* 131 */
191281168Spfg	"conversion from '%s' to '%s' may lose accuracy",	      /* 132 */
19212099Sjoerg	"conversion of pointer to '%s' loses bits",		      /* 133 */
19312099Sjoerg	"conversion of pointer to '%s' may lose bits",		      /* 134 */
19412099Sjoerg	"possible pointer alignment problem",			      /* 135 */
19512099Sjoerg	"cannot do pointer arithmetic on operand of unknown size",    /* 136 */
19612099Sjoerg	"use of incomplete enum type, op %s",			      /* 137 */
19712099Sjoerg	"unknown operand size, op %s",				      /* 138 */
19812099Sjoerg	"division by 0",					      /* 139 */
19912099Sjoerg	"modulus by 0",						      /* 140 */
20012099Sjoerg	"integer overflow detected, op %s",			      /* 141 */
20112099Sjoerg	"floating point overflow detected, op %s",		      /* 142 */
20212099Sjoerg	"cannot take size of incomplete type",			      /* 143 */
20312099Sjoerg	"cannot take size of function",				      /* 144 */
20412099Sjoerg	"cannot take size of bit-field",			      /* 145 */
20512099Sjoerg	"cannot take size of void",				      /* 146 */
20612099Sjoerg	"invalid cast expression",				      /* 147 */
20712099Sjoerg	"improper cast of void expression",			      /* 148 */
20812099Sjoerg	"illegal function",					      /* 149 */
20912099Sjoerg	"argument mismatch: %d arg%s passed, %d expected",	      /* 150 */
21012099Sjoerg	"void expressions may not be arguments, arg #%d",	      /* 151 */
21112099Sjoerg	"argument cannot have unknown size, arg #%d",		      /* 152 */
21212099Sjoerg	"argument has incompatible pointer type, arg #%d",	      /* 153 */
21312099Sjoerg	"illegal combination of pointer and integer, arg #%d",	      /* 154 */
21412099Sjoerg	"argument is incompatible with prototype, arg #%d",	      /* 155 */
21512099Sjoerg	"enum type mismatch, arg #%d",			       	      /* 156 */
21612099Sjoerg	"ANSI C treats constant as unsigned",			      /* 157 */
21712099Sjoerg	"%s may be used before set",			      	      /* 158 */
21812099Sjoerg	"assignment in conditional context",			      /* 159 */
21912099Sjoerg	"operator '==' found where '=' was expected",		      /* 160 */
22012099Sjoerg	"constant in conditional context",			      /* 161 */
22175697Sasmodai	"comparison of %s with %s, op %s",			      /* 162 */
22212099Sjoerg	"a cast does not yield an lvalue",			      /* 163 */
22312099Sjoerg	"assignment of negative constant to unsigned type",	      /* 164 */
22412099Sjoerg	"constant truncated by assignment",			      /* 165 */
22512099Sjoerg	"precision lost in bit-field assignment",		      /* 166 */
22612099Sjoerg	"array subscript cannot be negative: %ld",		      /* 167 */
22712099Sjoerg	"array subscript cannot be > %d: %ld",			      /* 168 */
22812099Sjoerg	"precedence confusion possible: parenthesize!",		      /* 169 */
22912099Sjoerg	"first operand must have scalar type, op ? :",		      /* 170 */
23012099Sjoerg	"assignment type mismatch",				      /* 171 */
23112099Sjoerg	"too many struct/union initializers",			      /* 172 */
23212099Sjoerg	"too many array initializers",				      /* 173 */
23312099Sjoerg	"too many initializers",				      /* 174 */
23412099Sjoerg	"initialisation of an incomplete type",			      /* 175 */
235281168Spfg	"invalid initializer type %s",				      /* 176 */
23612099Sjoerg	"non-constant initializer",				      /* 177 */
23712099Sjoerg	"initializer does not fit",				      /* 178 */
23812099Sjoerg	"cannot initialize struct/union with no named member",	      /* 179 */
23912099Sjoerg	"bit-field initializer does not fit",			      /* 180 */
24012099Sjoerg	"{}-enclosed initializer required",			      /* 181 */
24112099Sjoerg	"incompatible pointer types",				      /* 182 */
24212099Sjoerg	"illegal combination of pointer and integer",		      /* 183 */
24312099Sjoerg	"illegal pointer combination",				      /* 184 */
24412099Sjoerg	"initialisation type mismatch",				      /* 185 */
24512099Sjoerg	"bit-field initialisation is illegal in traditional C",	      /* 186 */
24612099Sjoerg	"non-null byte ignored in string initializer",		      /* 187 */
24712099Sjoerg	"no automatic aggregate initialization in traditional C",     /* 188 */
24812099Sjoerg	"assignment of struct/union illegal in traditional C",	      /* 189 */
24912099Sjoerg	"empty array declaration: %s",				      /* 190 */
25012099Sjoerg	"%s set but not used in function %s",		      	      /* 191 */
25112099Sjoerg	"%s unused in function %s",				      /* 192 */
25212099Sjoerg	"statement not reached",				      /* 193 */
25312099Sjoerg	"label %s redefined",					      /* 194 */
25412099Sjoerg	"case not in switch",					      /* 195 */
25512099Sjoerg	"case label affected by conversion",			      /* 196 */
25612099Sjoerg	"non-constant case expression",				      /* 197 */
25712099Sjoerg	"non-integral case expression",				      /* 198 */
25812099Sjoerg	"duplicate case in switch: %ld",			      /* 199 */
25912099Sjoerg	"duplicate case in switch: %lu",			      /* 200 */
26012099Sjoerg	"default outside switch",				      /* 201 */
26112099Sjoerg	"duplicate default in switch",				      /* 202 */
26212099Sjoerg	"case label must be of type `int' in traditional C",	      /* 203 */
26312099Sjoerg	"controlling expressions must have scalar type",	      /* 204 */
26412099Sjoerg	"switch expression must have integral type",		      /* 205 */
26512099Sjoerg	"enumeration value(s) not handled in switch",		      /* 206 */
26612099Sjoerg	"loop not entered at top",				      /* 207 */
26712099Sjoerg	"break outside loop or switch",				      /* 208 */
26812099Sjoerg	"continue outside loop",				      /* 209 */
26912099Sjoerg	"enum type mismatch in initialisation",			      /* 210 */
27012099Sjoerg	"return value type mismatch",				      /* 211 */
27112099Sjoerg	"cannot return incomplete type",			      /* 212 */
27212099Sjoerg	"void function %s cannot return value",			      /* 213 */
27312099Sjoerg	"function %s expects to return value",			      /* 214 */
27412099Sjoerg	"function implicitly declared to return int",		      /* 215 */
27512099Sjoerg	"function %s has return (e); and return;",		      /* 216 */
27612099Sjoerg	"function %s falls off bottom without returning value",	      /* 217 */
27712099Sjoerg	"ANSI C treats constant as unsigned, op %s",		      /* 218 */
27812099Sjoerg	"concatenated strings are illegal in traditional C",	      /* 219 */
27912099Sjoerg	"fallthrough on case statement",			      /* 220 */
28012099Sjoerg	"initialisation of unsigned with negative constant",	      /* 221 */
28112099Sjoerg	"conversion of negative constant to unsigned type",	      /* 222 */
28212099Sjoerg	"end-of-loop code not reached",				      /* 223 */
28312099Sjoerg	"cannot recover from previous errors",			      /* 224 */
28412099Sjoerg	"static function called but not defined: %s()",		      /* 225 */
28512099Sjoerg	"static variable %s unused",				      /* 226 */
28612099Sjoerg	"const object %s should have initializer",		      /* 227 */
28712099Sjoerg	"function cannot return const or volatile object",	      /* 228 */
28812099Sjoerg	"questionable conversion of function pointer",		      /* 229 */
28975697Sasmodai	"nonportable character comparison, op %s",		      /* 230 */
29012099Sjoerg	"argument %s unused in function %s",			      /* 231 */
29112099Sjoerg	"label %s unused in function %s",			      /* 232 */
29212099Sjoerg	"struct %s never defined",				      /* 233 */
29312099Sjoerg	"union %s never defined",				      /* 234 */
29412099Sjoerg	"enum %s never defined",				      /* 235 */
29512099Sjoerg	"static function %s unused",				      /* 236 */
29612099Sjoerg	"redeclaration of formal parameter %s",			      /* 237 */
29712099Sjoerg	"initialisation of union is illegal in traditional C",	      /* 238 */
29812099Sjoerg	"constant argument to NOT",				      /* 239 */
29912099Sjoerg	"assignment of different structures",			      /* 240 */
30012099Sjoerg	"dubious operation on enum, op %s",			      /* 241 */
30112099Sjoerg	"combination of '%s' and '%s', op %s",			      /* 242 */
30275697Sasmodai	"dubious comparison of enums, op %s",			      /* 243 */
30312099Sjoerg	"illegal structure pointer combination",		      /* 244 */
30412099Sjoerg	"illegal structure pointer combination, op %s",		      /* 245 */
30512099Sjoerg	"dubious conversion of enum to '%s'",			      /* 246 */
30612099Sjoerg	"pointer casts may be troublesome",			      /* 247 */
30712099Sjoerg	"floating-point constant out of range",			      /* 248 */
30812099Sjoerg	"syntax error",						      /* 249 */
30912099Sjoerg	"unknown character \\%o",				      /* 250 */
31012099Sjoerg	"malformed integer constant",				      /* 251 */
31112099Sjoerg	"integer constant out of range",			      /* 252 */
31212099Sjoerg	"unterminated character constant",			      /* 253 */
31312099Sjoerg	"newline in string or char constant",			      /* 254 */
31412099Sjoerg	"undefined or invalid # directive",			      /* 255 */
31512099Sjoerg	"unterminated comment",					      /* 256 */
31612099Sjoerg	"extra characters in lint comment",			      /* 257 */
31712099Sjoerg	"unterminated string constant",				      /* 258 */
31812099Sjoerg	"conversion to '%s' due to prototype, arg #%d",		      /* 259 */
31912099Sjoerg	"previous declaration of %s",				      /* 260 */
32012099Sjoerg	"previous definition of %s",				      /* 261 */
32112099Sjoerg	"\\\" inside character constants undefined in traditional C", /* 262 */
32212099Sjoerg	"\\? undefined in traditional C",			      /* 263 */
32312099Sjoerg	"\\v undefined in traditional C",			      /* 264 */
32412099Sjoerg	"%s C does not support 'long long'",			      /* 265 */
32512099Sjoerg	"'long double' is illegal in traditional C",		      /* 266 */
32612099Sjoerg	"shift equal to size of object",			      /* 267 */
32712099Sjoerg	"variable declared inline: %s",				      /* 268 */
32812099Sjoerg	"argument declared inline: %s",				      /* 269 */
32912099Sjoerg	"function prototypes are illegal in traditional C",	      /* 270 */
33012099Sjoerg	"switch expression must be of type `int' in traditional C",   /* 271 */
33112099Sjoerg	"empty translation unit",				      /* 272 */
33212099Sjoerg	"bit-field type '%s' invalid in ANSI C",		      /* 273 */
33375697Sasmodai	"ANSI C forbids comparison of %s with %s",		      /* 274 */
33412099Sjoerg	"cast discards 'const' from pointer target type",	      /* 275 */
33512099Sjoerg	"",							      /* 276 */
33612099Sjoerg	"initialisation of '%s' with '%s'",			      /* 277 */
33712099Sjoerg	"combination of '%s' and '%s', arg #%d",		      /* 278 */
33812099Sjoerg	"combination of '%s' and '%s' in return",		      /* 279 */
33912099Sjoerg	"must be outside function: /* %s */",			      /* 280 */
34012099Sjoerg	"duplicate use of /* %s */",				      /* 281 */
34112099Sjoerg	"must precede function definition: /* %s */",		      /* 282 */
34212099Sjoerg	"argument number mismatch with directive: /* %s */",	      /* 283 */
34312099Sjoerg	"fallthrough on default statement",			      /* 284 */
34412099Sjoerg	"prototype declaration",				      /* 285 */
34512099Sjoerg	"function definition is not a prototype",		      /* 286 */
34612099Sjoerg	"function declaration is not a prototype",		      /* 287 */
34712099Sjoerg	"dubious use of /* VARARGS */ with /* %s */",		      /* 288 */
34812099Sjoerg	"can't be used together: /* PRINTFLIKE */ /* SCANFLIKE */",   /* 289 */
34912099Sjoerg	"static function %s declared but not defined",		      /* 290 */
35012099Sjoerg	"invalid multibyte character",				      /* 291 */
35112099Sjoerg	"cannot concatenate wide and regular string literals",	      /* 292 */
35212099Sjoerg	"argument %d must be 'char *' for PRINTFLIKE/SCANFLIKE",      /* 293 */
35312099Sjoerg	"multi-character character constant",			      /* 294 */
35412099Sjoerg	"conversion of '%s' to '%s' is out of range, arg #%d",	      /* 295 */
35512099Sjoerg	"conversion of negative constant to unsigned type, arg #%d",  /* 296 */
35612099Sjoerg	"conversion to '%s' may sign-extend incorrectly, arg #%d",    /* 297 */
357281168Spfg	"conversion from '%s' to '%s' may lose accuracy, arg #%d",    /* 298 */
35812099Sjoerg	"prototype does not match old style definition, arg #%d",     /* 299 */
35912099Sjoerg	"old style definition",					      /* 300 */
36012099Sjoerg	"array of incomplete type",				      /* 301 */
36112099Sjoerg	"%s returns pointer to automatic object",		      /* 302 */
36212099Sjoerg	"ANSI C forbids conversion of %s to %s",		      /* 303 */
36312099Sjoerg	"ANSI C forbids conversion of %s to %s, arg #%d",	      /* 304 */
36412099Sjoerg	"ANSI C forbids conversion of %s to %s, op %s",		      /* 305 */
36512099Sjoerg	"constant truncated by conversion, op %s",		      /* 306 */
36612099Sjoerg	"static variable %s set but not used",			      /* 307 */
36712099Sjoerg	"",							      /* 308 */
36812099Sjoerg	"extra bits set to 0 in conversion of '%s' to '%s', op %s",   /* 309 */
36991592Smarkm	"symbol renaming can't be used on function arguments",	      /* 310 */
37091592Smarkm	"symbol renaming can't be used on automatic variables",	      /* 311 */
37191592Smarkm	"%s C does not support // comments",			      /* 312 */
372281168Spfg	"struct or union member name in initializer is a C9X feature",/* 313 */
373281168Spfg	"%s is not a structure or a union",			      /* 314 */
374281168Spfg	"GCC style struct or union member name in initializer",	      /* 315 */
375281168Spfg	"__FUNCTION__ is a GCC extension",			      /* 316 */
376281168Spfg	"__func__ is a C9X feature",				      /* 317 */
377281168Spfg	"variable array dimension is a C99/GCC extension",	      /* 318 */
378281168Spfg	"compound literals are a C9X/GCC extension",		      /* 319 */
379281168Spfg	"({ }) is a GCC extension",				      /* 320 */
380281168Spfg	"array initializer with designators is a C9X feature",	      /* 321 */
381281168Spfg	"zero sized array is a C99 extension",			      /* 322 */
38212099Sjoerg};
38312099Sjoerg
38412099Sjoerg/*
38591592Smarkm * print a list of the messages with their ids
38691592Smarkm */
38791592Smarkmvoid
38891592Smarkmmsglist(void)
38991592Smarkm{
390281168Spfg	size_t i;
39191592Smarkm
39291592Smarkm	for (i = 0; i < sizeof(msgs) / sizeof(msgs[0]); i++)
393281168Spfg		printf("%zu\t%s\n", i, msgs[i]);
39491592Smarkm}
39591592Smarkm
39691592Smarkm/*
397100364Smarkm * If Fflag is not set lbasename() returns a pointer to the last
39812099Sjoerg * component of the path, otherwise it returns the argument.
39912099Sjoerg */
40012099Sjoergstatic const char *
401100364Smarkmlbasename(const char *path)
40212099Sjoerg{
40312099Sjoerg	const	char *cp, *cp1, *cp2;
40412099Sjoerg
40512099Sjoerg	if (Fflag)
40612099Sjoerg		return (path);
40712099Sjoerg
40812099Sjoerg	cp = cp1 = cp2 = path;
40912099Sjoerg	while (*cp != '\0') {
41012099Sjoerg		if (*cp++ == '/') {
41112099Sjoerg			cp2 = cp1;
41212099Sjoerg			cp1 = cp;
41312099Sjoerg		}
41412099Sjoerg	}
41512099Sjoerg	return (*cp1 == '\0' ? cp2 : cp1);
41612099Sjoerg}
41712099Sjoerg
41812099Sjoergstatic void
41991592Smarkmverror( int n, va_list ap)
42012099Sjoerg{
42112099Sjoerg	const	char *fn;
42212099Sjoerg
42391592Smarkm	if (ERR_ISSET(n, &msgset))
42491592Smarkm		return;
42591592Smarkm
426100364Smarkm	fn = lbasename(curr_pos.p_file);
427100364Smarkm	(void)printf("%s(%d): ", fn, curr_pos.p_line);
42812099Sjoerg	(void)vprintf(msgs[n], ap);
42991592Smarkm	(void)printf(" [%d]\n", n);
43012099Sjoerg	nerr++;
43112099Sjoerg}
43212099Sjoerg
43312099Sjoergstatic void
43491592Smarkmvwarning( int n, va_list ap)
43512099Sjoerg{
43612099Sjoerg	const	char *fn;
43712099Sjoerg
43891592Smarkm	if (ERR_ISSET(n, &msgset))
43991592Smarkm		return;
44091592Smarkm
44112099Sjoerg	if (nowarn)
44212099Sjoerg		/* this warning is suppressed by a LINTED comment */
44312099Sjoerg		return;
44412099Sjoerg
445100364Smarkm	fn = lbasename(curr_pos.p_file);
446100364Smarkm	(void)printf("%s(%d): warning: ", fn, curr_pos.p_line);
44712099Sjoerg	(void)vprintf(msgs[n], ap);
44891592Smarkm	(void)printf(" [%d]\n", n);
44991592Smarkm	if (wflag)
45091592Smarkm		nerr++;
45112099Sjoerg}
45212099Sjoerg
45312099Sjoergvoid
45412099Sjoergerror(int n, ...)
45512099Sjoerg{
45612099Sjoerg	va_list	ap;
45712099Sjoerg
45812099Sjoerg	va_start(ap, n);
45912099Sjoerg	verror(n, ap);
46012099Sjoerg	va_end(ap);
46112099Sjoerg}
46212099Sjoerg
46312099Sjoergvoid
464281168Spfglerror(const char *file, int line, const char *msg, ...)
46512099Sjoerg{
46612099Sjoerg	va_list	ap;
46712099Sjoerg	const	char *fn;
46812099Sjoerg
46912099Sjoerg	va_start(ap, msg);
470100364Smarkm	fn = lbasename(curr_pos.p_file);
471281168Spfg	(void)fprintf(stderr, "%s(%d): lint error: %s, %d", fn, curr_pos.p_line,
472281168Spfg	    file, line);
47312099Sjoerg	(void)vfprintf(stderr, msg, ap);
47412099Sjoerg	(void)fprintf(stderr, "\n");
47512099Sjoerg	va_end(ap);
47612099Sjoerg	exit(1);
47712099Sjoerg}
47812099Sjoerg
47912099Sjoergvoid
48012099Sjoergwarning(int n, ...)
48112099Sjoerg{
48212099Sjoerg	va_list	ap;
48312099Sjoerg
48412099Sjoerg	va_start(ap, n);
48512099Sjoerg	vwarning(n, ap);
48612099Sjoerg	va_end(ap);
48712099Sjoerg}
48812099Sjoerg
48912099Sjoergvoid
49012099Sjoergmessage(int n, ...)
49112099Sjoerg{
49212099Sjoerg	va_list	ap;
49312099Sjoerg	const	char *fn;
49412099Sjoerg
49591592Smarkm	if (ERR_ISSET(n, &msgset))
49691592Smarkm		return;
49791592Smarkm
49812099Sjoerg	va_start(ap, n);
499100364Smarkm	fn = lbasename(curr_pos.p_file);
500100364Smarkm	(void)printf("%s(%d): ", fn, curr_pos.p_line);
50112099Sjoerg	(void)vprintf(msgs[n], ap);
50291592Smarkm	(void)printf(" [%d]\n", n);
50312099Sjoerg	va_end(ap);
50412099Sjoerg}
50512099Sjoerg
506281168Spfg/*
507281168Spfg * XXX I think the logic is possibly somewhat screwed up here. The
508281168Spfg * question is, how do we want to interpret the -s and -S flags going
509281168Spfg * forward? We need to answer that and then we can fix this to be
510281168Spfg * "right"... [perry, 2 Nov 2002]
511281168Spfg*/
51212099Sjoergint
513281168Spfgc99ism(int n, ...)
514281168Spfg{
515281168Spfg	va_list	ap;
516281168Spfg	int	msg;
517281168Spfg
518281168Spfg	va_start(ap, n);
519281168Spfg	if (sflag && !(Sflag || gflag)) {
520281168Spfg		verror(n, ap);
521281168Spfg		msg = 1;
522281168Spfg	} else if (!sflag && (Sflag || gflag)) {
523281168Spfg		msg = 0;
524281168Spfg	} else {
525281168Spfg		vwarning(n, ap);
526281168Spfg		msg = 1;
527281168Spfg	}
528281168Spfg	va_end(ap);
529281168Spfg
530281168Spfg	return (msg);
531281168Spfg}
532281168Spfg
533281168Spfgint
53412099Sjoerggnuism(int n, ...)
53512099Sjoerg{
53612099Sjoerg	va_list	ap;
53712099Sjoerg	int	msg;
53812099Sjoerg
53912099Sjoerg	va_start(ap, n);
54012099Sjoerg	if (sflag && !gflag) {
54112099Sjoerg		verror(n, ap);
54212099Sjoerg		msg = 1;
54312099Sjoerg	} else if (!sflag && gflag) {
54412099Sjoerg		msg = 0;
54512099Sjoerg	} else {
54612099Sjoerg		vwarning(n, ap);
54712099Sjoerg		msg = 1;
54812099Sjoerg	}
54912099Sjoerg	va_end(ap);
55012099Sjoerg
55112099Sjoerg	return (msg);
55212099Sjoerg}
553