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