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