chk.c revision 1.3 1 /* $NetBSD: chk.c,v 1.3 1996/12/22 11:31:37 cgd Exp $ */
2
3 /*
4 * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
5 * Copyright (c) 1994, 1995 Jochen Pohl
6 * All Rights Reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by Jochen Pohl for
19 * The NetBSD Project.
20 * 4. The name of the author may not be used to endorse or promote products
21 * derived from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35 #ifndef lint
36 static char rcsid[] = "$NetBSD: chk.c,v 1.3 1996/12/22 11:31:37 cgd Exp $";
37 #endif
38
39 #include <stdlib.h>
40 #include <ctype.h>
41 #include <limits.h>
42 #include <err.h>
43
44 #include "lint2.h"
45
46 /* various type information */
47 ttab_t ttab[NTSPEC];
48
49
50 static void chkund __P((hte_t *));
51 static void chkdnu __P((hte_t *));
52 static void chkdnud __P((hte_t *));
53 static void chkmd __P((hte_t *));
54 static void chkvtui __P((hte_t *, sym_t *, sym_t *));
55 static void chkvtdi __P((hte_t *, sym_t *, sym_t *));
56 static void chkfaui __P((hte_t *, sym_t *, sym_t *));
57 static void chkau __P((hte_t *, int, sym_t *, sym_t *, pos_t *,
58 fcall_t *, fcall_t *, type_t *, type_t *));
59 static void chkrvu __P((hte_t *, sym_t *));
60 static void chkadecl __P((hte_t *, sym_t *, sym_t *));
61 static void printflike __P((hte_t *,fcall_t *, int,
62 const char *, type_t **));
63 static void scanflike __P((hte_t *, fcall_t *, int,
64 const char *, type_t **));
65 static void badfmt __P((hte_t *, fcall_t *));
66 static void inconarg __P((hte_t *, fcall_t *, int));
67 static void tofewarg __P((hte_t *, fcall_t *));
68 static void tomanyarg __P((hte_t *, fcall_t *));
69 static int eqtype __P((type_t *, type_t *, int, int, int, int *));
70 static int eqargs __P((type_t *, type_t *, int *));
71 static int mnoarg __P((type_t *, int *));
72
73
74 void
75 inittyp()
76 {
77 int i;
78 static struct {
79 tspec_t it_tspec;
80 ttab_t it_ttab;
81 } ittab[] = {
82 { SIGNED, { 0, 0,
83 SIGNED, UNSIGN,
84 0, 0, 0, 0, 0, "signed" } },
85 { UNSIGN, { 0, 0,
86 SIGNED, UNSIGN,
87 0, 0, 0, 0, 0, "unsigned" } },
88 { CHAR, { CHAR_BIT, CHAR_BIT,
89 SCHAR, UCHAR,
90 1, 0, 0, 1, 1, "char" } },
91 { SCHAR, { CHAR_BIT, CHAR_BIT,
92 SCHAR, UCHAR,
93 1, 0, 0, 1, 1, "signed char" } },
94 { UCHAR, { CHAR_BIT, CHAR_BIT,
95 SCHAR, UCHAR,
96 1, 1, 0, 1, 1, "unsigned char" } },
97 { SHORT, { sizeof (short) * CHAR_BIT, 2 * CHAR_BIT,
98 SHORT, USHORT,
99 1, 0, 0, 1, 1, "short" } },
100 { USHORT, { sizeof (u_short) * CHAR_BIT, 2 * CHAR_BIT,
101 SHORT, USHORT,
102 1, 1, 0, 1, 1, "unsigned short" } },
103 { INT, { sizeof (int) * CHAR_BIT, 3 * CHAR_BIT,
104 INT, UINT,
105 1, 0, 0, 1, 1, "int" } },
106 { UINT, { sizeof (u_int) * CHAR_BIT, 3 * CHAR_BIT,
107 INT, UINT,
108 1, 1, 0, 1, 1, "unsigned int" } },
109 { LONG, { sizeof (long) * CHAR_BIT, 4 * CHAR_BIT,
110 LONG, ULONG,
111 1, 0, 0, 1, 1, "long" } },
112 { ULONG, { sizeof (u_long) * CHAR_BIT, 4 * CHAR_BIT,
113 LONG, ULONG,
114 1, 1, 0, 1, 1, "unsigned long" } },
115 { QUAD, { sizeof (quad_t) * CHAR_BIT, 8 * CHAR_BIT,
116 QUAD, UQUAD,
117 1, 0, 0, 1, 1, "long long" } },
118 { UQUAD, { sizeof (u_quad_t) * CHAR_BIT, 8 * CHAR_BIT,
119 QUAD, UQUAD,
120 1, 1, 0, 1, 1, "unsigned long long" } },
121 { FLOAT, { sizeof (float) * CHAR_BIT, 4 * CHAR_BIT,
122 FLOAT, FLOAT,
123 0, 0, 1, 1, 1, "float" } },
124 { DOUBLE, { sizeof (double) * CHAR_BIT, 8 * CHAR_BIT,
125 DOUBLE, DOUBLE,
126 0, 0, 1, 1, 1, "double" } },
127 { LDOUBLE, { sizeof (ldbl_t) * CHAR_BIT, 10 * CHAR_BIT,
128 LDOUBLE, LDOUBLE,
129 0, 0, 1, 1, 1, "long double" } },
130 { VOID, { -1, -1,
131 VOID, VOID,
132 0, 0, 0, 0, 0, "void" } },
133 { STRUCT, { -1, -1,
134 STRUCT, STRUCT,
135 0, 0, 0, 0, 0, "struct" } },
136 { UNION, { -1, -1,
137 UNION, UNION,
138 0, 0, 0, 0, 0, "union" } },
139 { ENUM, { sizeof (int) * CHAR_BIT, 3 * CHAR_BIT,
140 ENUM, ENUM,
141 1, 0, 0, 1, 1, "enum" } },
142 { PTR, { sizeof (void *) * CHAR_BIT, 4 * CHAR_BIT,
143 PTR, PTR,
144 0, 1, 0, 0, 1, "pointer" } },
145 { ARRAY, { -1, -1,
146 ARRAY, ARRAY,
147 0, 0, 0, 0, 0, "array" } },
148 { FUNC, { -1, -1,
149 FUNC, FUNC,
150 0, 0, 0, 0, 0, "function" } },
151 };
152
153 for (i = 0; i < sizeof (ittab) / sizeof (ittab[0]); i++)
154 STRUCT_ASSIGN(ttab[ittab[i].it_tspec], ittab[i].it_ttab);
155 if (!pflag) {
156 for (i = 0; i < NTSPEC; i++)
157 ttab[i].tt_psz = ttab[i].tt_sz;
158 }
159 }
160
161
162 /*
163 * If there is a symbol named "main", mark it as used.
164 */
165 void
166 mainused()
167 {
168 hte_t *hte;
169
170 if ((hte = hsearch("main", 0)) != NULL)
171 hte->h_used = 1;
172 }
173
174 /*
175 * Performs all tests for a single name
176 */
177 void
178 chkname(hte)
179 hte_t *hte;
180 {
181 sym_t *sym, *def, *pdecl, *decl;
182
183 if (uflag) {
184 chkund(hte);
185 chkdnu(hte);
186 if (xflag)
187 chkdnud(hte);
188 }
189 chkmd(hte);
190
191 /* Get definition, prototype declaration and declaration */
192 def = pdecl = decl = NULL;
193 for (sym = hte->h_syms; sym != NULL; sym = sym->s_nxt) {
194 if (def == NULL && (sym->s_def == DEF || sym->s_def == TDEF))
195 def = sym;
196 if (pdecl == NULL && sym->s_def == DECL &&
197 TP(sym->s_type)->t_tspec == FUNC &&
198 TP(sym->s_type)->t_proto) {
199 pdecl = sym;
200 }
201 if (decl == NULL && sym->s_def == DECL)
202 decl = sym;
203 }
204
205 /* A prototype is better than an old style declaration. */
206 if (pdecl != NULL)
207 decl = pdecl;
208
209 chkvtui(hte, def, decl);
210
211 chkvtdi(hte, def, decl);
212
213 chkfaui(hte, def, decl);
214
215 chkrvu(hte, def);
216
217 chkadecl(hte, def, decl);
218 }
219
220 /*
221 * Print a warning if the name has been used, but not defined.
222 */
223 static void
224 chkund(hte)
225 hte_t *hte;
226 {
227 fcall_t *fcall;
228 usym_t *usym;
229
230 if (!hte->h_used || hte->h_def)
231 return;
232
233 if ((fcall = hte->h_calls) != NULL) {
234 /* %s used( %s ), but not defined */
235 msg(0, hte->h_name, mkpos(&fcall->f_pos));
236 } else if ((usym = hte->h_usyms) != NULL) {
237 /* %s used( %s ), but not defined */
238 msg(0, hte->h_name, mkpos(&usym->u_pos));
239 }
240 }
241
242 /*
243 * Print a warning if the name has been defined, but never used.
244 */
245 static void
246 chkdnu(hte)
247 hte_t *hte;
248 {
249 sym_t *sym;
250
251 if (!hte->h_def || hte->h_used)
252 return;
253
254 for (sym = hte->h_syms; sym != NULL; sym = sym->s_nxt) {
255 if (sym->s_def == DEF || sym->s_def == TDEF) {
256 /* %s defined( %s ), but never used */
257 msg(1, hte->h_name, mkpos(&sym->s_pos));
258 break;
259 }
260 }
261 }
262
263 /*
264 * Print a warning if the name has been declared, but is not used
265 * or defined.
266 */
267 static void
268 chkdnud(hte)
269 hte_t *hte;
270 {
271 sym_t *sym;
272
273 if (hte->h_syms == NULL || hte->h_used || hte->h_def)
274 return;
275
276 if ((sym = hte->h_syms) != NULL) {
277 if (sym->s_def != DECL)
278 errx(1, "internal error: chkdnud() 1");
279 /* %s declared( %s ), but never used or defined */
280 msg(2, hte->h_name, mkpos(&sym->s_pos));
281 }
282 }
283
284 /*
285 * Print a warning if there is more then one definition for
286 * this name.
287 */
288 static void
289 chkmd(hte)
290 hte_t *hte;
291 {
292 sym_t *sym, *def1;
293 char *pos1;
294
295 if (!hte->h_def)
296 return;
297
298 def1 = NULL;
299 for (sym = hte->h_syms; sym != NULL; sym = sym->s_nxt) {
300 /*
301 * ANSI C allows tentative definitions of the same name in
302 * only one compilation unit.
303 */
304 if (sym->s_def != DEF && (!sflag || sym->s_def != TDEF))
305 continue;
306 if (def1 == NULL) {
307 def1 = sym;
308 continue;
309 }
310 pos1 = xstrdup(mkpos(&def1->s_pos));
311 /* %s multiply defined\t%s :: %s */
312 msg(3, hte->h_name, pos1, mkpos(&sym->s_pos));
313 free(pos1);
314 }
315 }
316
317 /*
318 * Print a warning if the return value assumed for a function call
319 * differs from the return value of the function definition or
320 * function declaration.
321 *
322 * If no definition/declaration can be found, the assumed return values
323 * are always int. So there is no need to compare with another function
324 * call as it's done for function arguments.
325 */
326 static void
327 chkvtui(hte, def, decl)
328 hte_t *hte;
329 sym_t *def, *decl;
330 {
331 fcall_t *call;
332 char *pos1;
333 type_t *tp1, *tp2;
334 /* LINTED (automatic hides external declaration: warn) */
335 int warn, eq;
336 tspec_t t1;
337
338 if (hte->h_calls == NULL)
339 return;
340
341 if (def == NULL)
342 def = decl;
343 if (def == NULL)
344 return;
345
346 t1 = (tp1 = TP(def->s_type)->t_subt)->t_tspec;
347 for (call = hte->h_calls; call != NULL; call = call->f_nxt) {
348 tp2 = TP(call->f_type)->t_subt;
349 eq = eqtype(tp1, tp2, 1, 0, 0, (warn = 0, &warn));
350 if (!call->f_rused) {
351 /* no return value used */
352 if ((t1 == STRUCT || t1 == UNION) && !eq) {
353 /*
354 * If a function returns a struct or union it
355 * must be declared to return a struct or
356 * union, also if the return value is ignored.
357 * This is necessary because the caller must
358 * allocate stack space for the return value.
359 * If it does not, the return value would over-
360 * write other data.
361 * XXX Following massage may be confusing
362 * because it appears also if the return value
363 * was declared inconsistently. But this
364 * behaviour matches pcc based lint, so it is
365 * accepted for now.
366 */
367 pos1 = xstrdup(mkpos(&def->s_pos));
368 /* %s value must be decl. before use %s :: %s */
369 msg(17, hte->h_name,
370 pos1, mkpos(&call->f_pos));
371 free(pos1);
372 }
373 continue;
374 }
375 if (!eq || (sflag && warn)) {
376 pos1 = xstrdup(mkpos(&def->s_pos));
377 /* %s value used inconsistenty\t%s :: %s */
378 msg(4, hte->h_name, pos1, mkpos(&call->f_pos));
379 free(pos1);
380 }
381 }
382 }
383
384 /*
385 * Print a warning if a definition/declaration does not match another
386 * definition/declaration of the same name. For functions, only the
387 * types of return values are tested.
388 */
389 static void
390 chkvtdi(hte, def, decl)
391 hte_t *hte;
392 sym_t *def, *decl;
393 {
394 sym_t *sym;
395 type_t *tp1, *tp2;
396 /* LINTED (automatic hides external declaration: warn) */
397 int eq, warn;
398 char *pos1;
399
400 if (def == NULL)
401 def = decl;
402 if (def == NULL)
403 return;
404
405 tp1 = TP(def->s_type);
406 for (sym = hte->h_syms; sym != NULL; sym = sym->s_nxt) {
407 if (sym == def)
408 continue;
409 tp2 = TP(sym->s_type);
410 warn = 0;
411 if (tp1->t_tspec == FUNC && tp2->t_tspec == FUNC) {
412 eq = eqtype(tp1->t_subt, tp2->t_subt, 1, 0, 0, &warn);
413 } else {
414 eq = eqtype(tp1, tp2, 0, 0, 0, &warn);
415 }
416 if (!eq || (sflag && warn)) {
417 pos1 = xstrdup(mkpos(&def->s_pos));
418 /* %s value declared inconsistently\t%s :: %s */
419 msg(5, hte->h_name, pos1, mkpos(&sym->s_pos));
420 free(pos1);
421 }
422 }
423 }
424
425 /*
426 * Print a warning if a function is called with arguments which does
427 * not match the function definition, declaration or another call
428 * of the same function.
429 */
430 static void
431 chkfaui(hte, def, decl)
432 hte_t *hte;
433 sym_t *def, *decl;
434 {
435 type_t *tp1, *tp2, **ap1, **ap2;
436 pos_t *pos1p;
437 fcall_t *calls, *call, *call1;
438 int n, as;
439 char *pos1;
440 arginf_t *ai;
441
442 if ((calls = hte->h_calls) == NULL)
443 return;
444
445 /*
446 * If we find a function definition, we use this for comparision,
447 * otherwise the first prototype we can find. If there is no
448 * definition or prototype declaration, the first function call
449 * is used.
450 */
451 tp1 = NULL;
452 call1 = NULL;
453 if (def != NULL) {
454 if ((tp1 = TP(def->s_type))->t_tspec != FUNC)
455 return;
456 pos1p = &def->s_pos;
457 } else if (decl != NULL && TP(decl->s_type)->t_proto) {
458 if ((tp1 = TP(decl->s_type))->t_tspec != FUNC)
459 return;
460 pos1p = &decl->s_pos;
461 }
462 if (tp1 == NULL) {
463 call1 = calls;
464 calls = calls->f_nxt;
465 if ((tp1 = TP(call1->f_type))->t_tspec != FUNC)
466 return;
467 pos1p = &call1->f_pos;
468 }
469
470 n = 1;
471 for (call = calls; call != NULL; call = call->f_nxt) {
472 if ((tp2 = TP(call->f_type))->t_tspec != FUNC)
473 continue;
474 ap1 = tp1->t_args;
475 ap2 = tp2->t_args;
476 n = 0;
477 while (*ap1 != NULL && *ap2 != NULL) {
478 if (def != NULL && def->s_va && n >= def->s_nva)
479 break;
480 n++;
481 chkau(hte, n, def, decl, pos1p, call1, call,
482 *ap1, *ap2);
483 ap1++;
484 ap2++;
485 }
486 if (*ap1 == *ap2) {
487 /* equal # of arguments */
488 } else if (def != NULL && def->s_va && n >= def->s_nva) {
489 /*
490 * function definition with VARARGS; The # of
491 * arguments of the call must be at least as large
492 * as the parameter of VARARGS.
493 */
494 } else if (*ap2 != NULL && tp1->t_proto && tp1->t_vararg) {
495 /*
496 * prototype with ... and function call with
497 * at least the same # of arguments as declared
498 * in the prototype.
499 */
500 } else {
501 pos1 = xstrdup(mkpos(pos1p));
502 /* %s: variable # of args\t%s :: %s */
503 msg(7, hte->h_name, pos1, mkpos(&call->f_pos));
504 free(pos1);
505 continue;
506 }
507
508 /* perform SCANFLIKE/PRINTFLIKE tests */
509 if (def == NULL || (!def->s_prfl && !def->s_scfl))
510 continue;
511 as = def->s_prfl ? def->s_nprfl : def->s_nscfl;
512 for (ai = call->f_args; ai != NULL; ai = ai->a_nxt) {
513 if (ai->a_num == as)
514 break;
515 }
516 if (ai == NULL || !ai->a_fmt)
517 continue;
518 if (def->s_prfl) {
519 printflike(hte, call, n, ai->a_fstrg, ap2);
520 } else {
521 scanflike(hte, call, n, ai->a_fstrg, ap2);
522 }
523 }
524 }
525
526 /*
527 * Check a single argument in a function call.
528 *
529 * hte a pointer to the hash table entry of the function
530 * n the number of the argument (1..)
531 * def the function definition or NULL
532 * decl prototype declaration, old style declaration or NULL
533 * pos1p position of definition, declaration of first call
534 * call1 first call, if both def and decl are old style def/decl
535 * call checked call
536 * arg1 currently checked argument of def/decl/call1
537 * arg2 currently checked argument of call
538 *
539 */
540 static void
541 chkau(hte, n, def, decl, pos1p, call1, call, arg1, arg2)
542 hte_t *hte;
543 int n;
544 sym_t *def, *decl;
545 pos_t *pos1p;
546 fcall_t *call1, *call;
547 type_t *arg1, *arg2;
548 {
549 /* LINTED (automatic hides external declaration: warn) */
550 int promote, asgn, warn;
551 tspec_t t1, t2;
552 arginf_t *ai, *ai1;
553 char *pos1;
554
555 /*
556 * If a function definition is available (def != NULL), we compair the
557 * function call (call) with the definition. Otherwise, if a function
558 * definition is available and it is not an old style definition
559 * (decl != NULL && TP(decl->s_type)->t_proto), we compair the call
560 * with this declaration. Otherwise we compair it with the first
561 * call we have found (call1).
562 */
563
564 /* arg1 must be promoted if it stems from an old style definition */
565 promote = def != NULL && def->s_osdef;
566
567 /*
568 * If we compair with a definition or declaration, we must perform
569 * the same checks for qualifiers in indirected types as in
570 * assignments.
571 */
572 asgn = def != NULL || (decl != NULL && TP(decl->s_type)->t_proto);
573
574 warn = 0;
575 if (eqtype(arg1, arg2, 1, promote, asgn, &warn) && (!sflag || !warn))
576 return;
577
578 /*
579 * Other lint implementations print warnings as soon as the type
580 * of an argument does not match exactly the expected type. The
581 * result are lots of warnings which are really not neccessary.
582 * We print a warning only if
583 * (0) at least one type is not an interger type and types differ
584 * (1) hflag is set and types differ
585 * (2) types differ, except in signedness
586 * If the argument is an integer constant whose msb is not set,
587 * signedness is ignored (e.g. 0 matches both signed and unsigned
588 * int). This is with and without hflag.
589 * If the argument is an integer constant with value 0 and the
590 * expected argument is of type pointer and the width of the
591 * interger constant is the same as the width of the pointer,
592 * no warning is printed.
593 */
594 t1 = arg1->t_tspec;
595 t2 = arg2->t_tspec;
596 if (isityp(t1) && isityp(t2) && !arg1->t_isenum && !arg2->t_isenum) {
597 if (promote) {
598 /*
599 * XXX Here is a problem: Althrough it is possible to
600 * pass an int where a char/short it expected, there
601 * may be loss in significant digits. We should first
602 * check for const arguments if they can be converted
603 * into the original parameter type.
604 */
605 if (t1 == FLOAT) {
606 t1 = DOUBLE;
607 } else if (t1 == CHAR || t1 == SCHAR) {
608 t1 = INT;
609 } else if (t1 == UCHAR) {
610 t1 = tflag ? UINT : INT;
611 } else if (t1 == SHORT) {
612 t1 = INT;
613 } else if (t1 == USHORT) {
614 /* CONSTCOND */
615 t1 = INT_MAX < USHRT_MAX || tflag ? UINT : INT;
616 }
617 }
618
619 if (styp(t1) == styp(t2)) {
620
621 /*
622 * types differ only in signedness; get information
623 * about arguments
624 */
625
626 /*
627 * treat a definition like a call with variable
628 * arguments
629 */
630 ai1 = call1 != NULL ? call1->f_args : NULL;
631
632 /*
633 * if two calls are compared, ai1 is set to the
634 * information for the n-th argument, if this was
635 * a constant, otherwise to NULL
636 */
637 for ( ; ai1 != NULL; ai1 = ai1->a_nxt) {
638 if (ai1->a_num == n)
639 break;
640 }
641 /*
642 * ai is set to the information of the n-th arg
643 * of the (second) call, if this was a constant,
644 * otherwise to NULL
645 */
646 for (ai = call->f_args; ai != NULL; ai = ai->a_nxt) {
647 if (ai->a_num == n)
648 break;
649 }
650
651 if (ai1 == NULL && ai == NULL) {
652 /* no constant at all */
653 if (!hflag)
654 return;
655 } else if (ai1 == NULL || ai == NULL) {
656 /* one constant */
657 if (ai == NULL)
658 ai = ai1;
659 if (ai->a_zero || ai->a_pcon)
660 /* same value in signed and unsigned */
661 return;
662 /* value (not representation) differently */
663 } else {
664 /*
665 * two constants, one signed, one unsigned;
666 * if the msb of one of the constants is set,
667 * the argument is used inconsistently.
668 */
669 if (!ai1->a_ncon && !ai->a_ncon)
670 return;
671 }
672 }
673
674 } else if (t1 == PTR && isityp(t2)) {
675 for (ai = call->f_args; ai != NULL; ai = ai->a_nxt) {
676 if (ai->a_num == n)
677 break;
678 }
679 /*
680 * Vendor implementations of lint (e.g. HP-UX, Digital UNIX)
681 * don't care about the size of the integer argument,
682 * only whether or not it is zero. We do the same.
683 */
684 if (ai != NULL && ai->a_zero)
685 return;
686 }
687
688 pos1 = xstrdup(mkpos(pos1p));
689 /* %s, arg %d used inconsistently\t%s :: %s */
690 msg(6, hte->h_name, n, pos1, mkpos(&call->f_pos));
691 free(pos1);
692 }
693
694 /*
695 * Compare the types in the NULL-terminated array ap with the format
696 * string fmt.
697 */
698 static void
699 printflike(hte, call, n, fmt, ap)
700 hte_t *hte;
701 fcall_t *call;
702 int n;
703 const char *fmt;
704 type_t **ap;
705 {
706 const char *fp;
707 int fc;
708 int fwidth, prec, left, sign, space, alt, zero;
709 tspec_t sz, t1, t2;
710 type_t *tp;
711
712 fp = fmt;
713 fc = *fp++;
714
715 for ( ; ; ) {
716 if (fc == '\0') {
717 if (*ap != NULL)
718 tomanyarg(hte, call);
719 break;
720 }
721 if (fc != '%') {
722 badfmt(hte, call);
723 break;
724 }
725 fc = *fp++;
726 fwidth = prec = left = sign = space = alt = zero = 0;
727 sz = NOTSPEC;
728
729 /* Flags */
730 for ( ; ; ) {
731 if (fc == '-') {
732 if (left)
733 break;
734 left = 1;
735 } else if (fc == '+') {
736 if (sign)
737 break;
738 sign = 1;
739 } else if (fc == ' ') {
740 if (space)
741 break;
742 space = 1;
743 } else if (fc == '#') {
744 if (alt)
745 break;
746 alt = 1;
747 } else if (fc == '0') {
748 if (zero)
749 break;
750 zero = 1;
751 } else {
752 break;
753 }
754 fc = *fp++;
755 }
756
757 /* field width */
758 if (isdigit(fc)) {
759 fwidth = 1;
760 do { fc = *fp++; } while (isdigit(fc)) ;
761 } else if (fc == '*') {
762 fwidth = 1;
763 fc = *fp++;
764 if ((tp = *ap++) == NULL) {
765 tofewarg(hte, call);
766 break;
767 }
768 n++;
769 if ((t1 = tp->t_tspec) != INT && (hflag || t1 != UINT))
770 inconarg(hte, call, n);
771 }
772
773 /* precision */
774 if (fc == '.') {
775 fc = *fp++;
776 prec = 1;
777 if (isdigit(fc)) {
778 do { fc = *fp++; } while (isdigit(fc));
779 } else if (fc == '*') {
780 fc = *fp++;
781 if ((tp = *ap++) == NULL) {
782 tofewarg(hte, call);
783 break;
784 }
785 n++;
786 if (tp->t_tspec != INT)
787 inconarg(hte, call, n);
788 } else {
789 badfmt(hte, call);
790 break;
791 }
792 }
793
794 if (fc == 'h') {
795 sz = SHORT;
796 } else if (fc == 'l') {
797 sz = LONG;
798 } else if (fc == 'q') {
799 sz = QUAD;
800 } else if (fc == 'L') {
801 sz = LDOUBLE;
802 }
803 if (sz != NOTSPEC)
804 fc = *fp++;
805
806 if (fc == '%') {
807 if (sz != NOTSPEC || left || sign || space ||
808 alt || zero || prec || fwidth) {
809 badfmt(hte, call);
810 }
811 fc = *fp++;
812 continue;
813 }
814
815 if (fc == '\0') {
816 badfmt(hte, call);
817 break;
818 }
819
820 if ((tp = *ap++) == NULL) {
821 tofewarg(hte, call);
822 break;
823 }
824 n++;
825 if ((t1 = tp->t_tspec) == PTR)
826 t2 = tp->t_subt->t_tspec;
827
828 if (fc == 'd' || fc == 'i') {
829 if (alt || sz == LDOUBLE) {
830 badfmt(hte, call);
831 break;
832 }
833 int_conv:
834 if (sz == LONG) {
835 if (t1 != LONG && (hflag || t1 != ULONG))
836 inconarg(hte, call, n);
837 } else if (sz == QUAD) {
838 if (t1 != QUAD && (hflag || t1 != UQUAD))
839 inconarg(hte, call, n);
840 } else {
841 /*
842 * SHORT is always promoted to INT, USHORT
843 * to INT or UINT.
844 */
845 if (t1 != INT && (hflag || t1 != UINT))
846 inconarg(hte, call, n);
847 }
848 } else if (fc == 'o' || fc == 'u' || fc == 'x' || fc == 'X') {
849 if ((alt && fc == 'u') || sz == LDOUBLE)
850 badfmt(hte, call);
851 uint_conv:
852 if (sz == LONG) {
853 if (t1 != ULONG && (hflag || t1 != LONG))
854 inconarg(hte, call, n);
855 } else if (sz == QUAD) {
856 if (t1 != UQUAD && (hflag || t1 != QUAD))
857 inconarg(hte, call, n);
858 } else if (sz == SHORT) {
859 /* USHORT was promoted to INT or UINT */
860 if (t1 != UINT && t1 != INT)
861 inconarg(hte, call, n);
862 } else {
863 if (t1 != UINT && (hflag || t1 != INT))
864 inconarg(hte, call, n);
865 }
866 } else if (fc == 'D' || fc == 'O' || fc == 'U') {
867 if ((alt && fc != 'O') || sz != NOTSPEC || !tflag)
868 badfmt(hte, call);
869 sz = LONG;
870 if (fc == 'D') {
871 goto int_conv;
872 } else {
873 goto uint_conv;
874 }
875 } else if (fc == 'f' || fc == 'e' || fc == 'E' ||
876 fc == 'g' || fc == 'G') {
877 if (sz == NOTSPEC)
878 sz = DOUBLE;
879 if (sz != DOUBLE && sz != LDOUBLE)
880 badfmt(hte, call);
881 if (t1 != sz)
882 inconarg(hte, call, n);
883 } else if (fc == 'c') {
884 if (sz != NOTSPEC || alt || zero)
885 badfmt(hte, call);
886 if (t1 != INT)
887 inconarg(hte, call, n);
888 } else if (fc == 's') {
889 if (sz != NOTSPEC || alt || zero)
890 badfmt(hte, call);
891 if (t1 != PTR ||
892 (t2 != CHAR && t2 != UCHAR && t2 != SCHAR)) {
893 inconarg(hte, call, n);
894 }
895 } else if (fc == 'p') {
896 if (fwidth || prec || sz != NOTSPEC || alt || zero)
897 badfmt(hte, call);
898 if (t1 != PTR || (hflag && t2 != VOID))
899 inconarg(hte, call, n);
900 } else if (fc == 'n') {
901 if (fwidth || prec || alt || zero || sz == LDOUBLE)
902 badfmt(hte, call);
903 if (t1 != PTR) {
904 inconarg(hte, call, n);
905 } else if (sz == LONG) {
906 if (t2 != LONG && t2 != ULONG)
907 inconarg(hte, call, n);
908 } else if (sz == SHORT) {
909 if (t2 != SHORT && t2 != USHORT)
910 inconarg(hte, call, n);
911 } else {
912 if (t2 != INT && t2 != UINT)
913 inconarg(hte, call, n);
914 }
915 } else {
916 badfmt(hte, call);
917 break;
918 }
919
920 fc = *fp++;
921 }
922 }
923
924 /*
925 * Compare the types in the NULL-terminated array ap with the format
926 * string fmt.
927 */
928 static void
929 scanflike(hte, call, n, fmt, ap)
930 hte_t *hte;
931 fcall_t *call;
932 int n;
933 const char *fmt;
934 type_t **ap;
935 {
936 const char *fp;
937 int fc;
938 int noasgn, fwidth;
939 tspec_t sz, t1, t2;
940 type_t *tp;
941
942 fp = fmt;
943 fc = *fp++;
944
945 for ( ; ; ) {
946 if (fc == '\0') {
947 if (*ap != NULL)
948 tomanyarg(hte, call);
949 break;
950 }
951 if (fc != '%') {
952 badfmt(hte, call);
953 break;
954 }
955 fc = *fp++;
956
957 noasgn = fwidth = 0;
958 sz = NOTSPEC;
959
960 if (fc == '*') {
961 noasgn = 1;
962 fc = *fp++;
963 }
964
965 if (isdigit(fc)) {
966 fwidth = 1;
967 do { fc = *fp++; } while (isdigit(fc));
968 }
969
970 if (fc == 'h') {
971 sz = SHORT;
972 } else if (fc == 'l') {
973 sz = LONG;
974 } else if (fc == 'q') {
975 sz = QUAD;
976 } else if (fc == 'L') {
977 sz = LDOUBLE;
978 }
979 if (sz != NOTSPEC)
980 fc = *fp++;
981
982 if (fc == '%') {
983 if (sz != NOTSPEC || noasgn || fwidth)
984 badfmt(hte, call);
985 fc = *fp++;
986 continue;
987 }
988
989 if (!noasgn) {
990 if ((tp = *ap++) == NULL) {
991 tofewarg(hte, call);
992 break;
993 }
994 n++;
995 if ((t1 = tp->t_tspec) == PTR)
996 t2 = tp->t_subt->t_tspec;
997 }
998
999 if (fc == 'd' || fc == 'i' || fc == 'n') {
1000 if (sz == LDOUBLE)
1001 badfmt(hte, call);
1002 if (sz != SHORT && sz != LONG && sz != QUAD)
1003 sz = INT;
1004 conv:
1005 if (!noasgn) {
1006 if (t1 != PTR) {
1007 inconarg(hte, call, n);
1008 } else if (t2 != styp(sz)) {
1009 inconarg(hte, call, n);
1010 } else if (hflag && t2 != sz) {
1011 inconarg(hte, call, n);
1012 } else if (tp->t_subt->t_const) {
1013 inconarg(hte, call, n);
1014 }
1015 }
1016 } else if (fc == 'o' || fc == 'u' || fc == 'x') {
1017 if (sz == LDOUBLE)
1018 badfmt(hte, call);
1019 if (sz == SHORT) {
1020 sz = USHORT;
1021 } else if (sz == LONG) {
1022 sz = ULONG;
1023 } else if (sz == QUAD) {
1024 sz = UQUAD;
1025 } else {
1026 sz = UINT;
1027 }
1028 goto conv;
1029 } else if (fc == 'D') {
1030 if (sz != NOTSPEC || !tflag)
1031 badfmt(hte, call);
1032 sz = LONG;
1033 goto conv;
1034 } else if (fc == 'O') {
1035 if (sz != NOTSPEC || !tflag)
1036 badfmt(hte, call);
1037 sz = ULONG;
1038 goto conv;
1039 } else if (fc == 'X') {
1040 /*
1041 * XXX valid in ANSI C, but in NetBSD's libc imple-
1042 * mented as "lx". Thats why it should be avoided.
1043 */
1044 if (sz != NOTSPEC || !tflag)
1045 badfmt(hte, call);
1046 sz = ULONG;
1047 goto conv;
1048 } else if (fc == 'E') {
1049 /*
1050 * XXX valid in ANSI C, but in NetBSD's libc imple-
1051 * mented as "lf". Thats why it should be avoided.
1052 */
1053 if (sz != NOTSPEC || !tflag)
1054 badfmt(hte, call);
1055 sz = DOUBLE;
1056 goto conv;
1057 } else if (fc == 'F') {
1058 /* XXX only for backward compatibility */
1059 if (sz != NOTSPEC || !tflag)
1060 badfmt(hte, call);
1061 sz = DOUBLE;
1062 goto conv;
1063 } else if (fc == 'G') {
1064 /*
1065 * XXX valid in ANSI C, but in NetBSD's libc not
1066 * implemented
1067 */
1068 if (sz != NOTSPEC && sz != LONG && sz != LDOUBLE)
1069 badfmt(hte, call);
1070 goto fconv;
1071 } else if (fc == 'e' || fc == 'f' || fc == 'g') {
1072 fconv:
1073 if (sz == NOTSPEC) {
1074 sz = FLOAT;
1075 } else if (sz == LONG) {
1076 sz = DOUBLE;
1077 } else if (sz != LDOUBLE) {
1078 badfmt(hte, call);
1079 sz = FLOAT;
1080 }
1081 goto conv;
1082 } else if (fc == 's' || fc == '[' || fc == 'c') {
1083 if (sz != NOTSPEC)
1084 badfmt(hte, call);
1085 if (fc == '[') {
1086 if ((fc = *fp++) == '-') {
1087 badfmt(hte, call);
1088 fc = *fp++;
1089 }
1090 if (fc != ']') {
1091 badfmt(hte, call);
1092 if (fc == '\0')
1093 break;
1094 }
1095 }
1096 if (!noasgn) {
1097 if (t1 != PTR) {
1098 inconarg(hte, call, n);
1099 } else if (t2 != CHAR && t2 != UCHAR &&
1100 t2 != SCHAR) {
1101 inconarg(hte, call, n);
1102 }
1103 }
1104 } else if (fc == 'p') {
1105 if (sz != NOTSPEC)
1106 badfmt(hte, call);
1107 if (!noasgn) {
1108 if (t1 != PTR || t2 != PTR) {
1109 inconarg(hte, call, n);
1110 } else if (tp->t_subt->t_subt->t_tspec!=VOID) {
1111 if (hflag)
1112 inconarg(hte, call, n);
1113 }
1114 }
1115 } else {
1116 badfmt(hte, call);
1117 break;
1118 }
1119
1120 fc = *fp++;
1121 }
1122 }
1123
1124 static void
1125 badfmt(hte, call)
1126 hte_t *hte;
1127 fcall_t *call;
1128 {
1129 /* %s: malformed format string\t%s */
1130 msg(13, hte->h_name, mkpos(&call->f_pos));
1131 }
1132
1133 static void
1134 inconarg(hte, call, n)
1135 hte_t *hte;
1136 fcall_t *call;
1137 int n;
1138 {
1139 /* %s, arg %d inconsistent with format\t%s(%d) */
1140 msg(14, hte->h_name, n, mkpos(&call->f_pos));
1141 }
1142
1143 static void
1144 tofewarg(hte, call)
1145 hte_t *hte;
1146 fcall_t *call;
1147 {
1148 /* %s: too few args for format \t%s */
1149 msg(15, hte->h_name, mkpos(&call->f_pos));
1150 }
1151
1152 static void
1153 tomanyarg(hte, call)
1154 hte_t *hte;
1155 fcall_t *call;
1156 {
1157 /* %s: too many args for format \t%s */
1158 msg(16, hte->h_name, mkpos(&call->f_pos));
1159 }
1160
1161
1162 /*
1163 * Print warnings for return values which are used, but not returned,
1164 * or return values which are always or sometimes ignored.
1165 */
1166 static void
1167 chkrvu(hte, def)
1168 hte_t *hte;
1169 sym_t *def;
1170 {
1171 fcall_t *call;
1172 int used, ignored;
1173
1174 if (def == NULL)
1175 /* don't know wheter or not the functions returns a value */
1176 return;
1177
1178 if (hte->h_calls == NULL)
1179 return;
1180
1181 if (def->s_rval) {
1182 /* function has return value */
1183 used = ignored = 0;
1184 for (call = hte->h_calls; call != NULL; call = call->f_nxt) {
1185 used |= call->f_rused;
1186 ignored |= !call->f_rused && !call->f_rdisc;
1187 }
1188 /*
1189 * XXX as soon as we are able to disable single warnings
1190 * the following dependencies from hflag should be removed.
1191 * but for now I do'nt want to be botherd by this warnings
1192 * which are almost always useless.
1193 */
1194 if (!used && ignored) {
1195 if (hflag)
1196 /* %s returns value which is always ignored */
1197 msg(8, hte->h_name);
1198 } else if (used && ignored) {
1199 if (hflag)
1200 /* %s returns value which is sometimes ign. */
1201 msg(9, hte->h_name);
1202 }
1203 } else {
1204 /* function has no return value */
1205 for (call = hte->h_calls; call != NULL; call = call->f_nxt) {
1206 if (call->f_rused)
1207 /* %s value is used( %s ), but none ret. */
1208 msg(10, hte->h_name, mkpos(&call->f_pos));
1209 }
1210 }
1211 }
1212
1213 /*
1214 * Print warnings for inconsistent argument declarations.
1215 */
1216 static void
1217 chkadecl(hte, def, decl)
1218 hte_t *hte;
1219 sym_t *def, *decl;
1220 {
1221 /* LINTED (automatic hides external declaration: warn) */
1222 int osdef, eq, warn, n;
1223 sym_t *sym1, *sym;
1224 type_t **ap1, **ap2, *tp1, *tp2;
1225 char *pos1;
1226 const char *pos2;
1227
1228 osdef = 0;
1229 if (def != NULL) {
1230 osdef = def->s_osdef;
1231 sym1 = def;
1232 } else if (decl != NULL && TP(decl->s_type)->t_proto) {
1233 sym1 = decl;
1234 } else {
1235 return;
1236 }
1237 if (TP(sym1->s_type)->t_tspec != FUNC)
1238 return;
1239
1240 /*
1241 * XXX Prototypes should also be compared with old style function
1242 * declarations.
1243 */
1244
1245 for (sym = hte->h_syms; sym != NULL; sym = sym->s_nxt) {
1246 if (sym == sym1 || !TP(sym->s_type)->t_proto)
1247 continue;
1248 ap1 = TP(sym1->s_type)->t_args;
1249 ap2 = TP(sym->s_type)->t_args;
1250 n = 0;
1251 while (*ap1 != NULL && *ap2 != NULL) {
1252 warn = 0;
1253 eq = eqtype(*ap1, *ap2, 1, osdef, 0, &warn);
1254 if (!eq || warn) {
1255 pos1 = xstrdup(mkpos(&sym1->s_pos));
1256 pos2 = mkpos(&sym->s_pos);
1257 /* %s, arg %d declared inconsistently ... */
1258 msg(11, hte->h_name, n + 1, pos1, pos2);
1259 free(pos1);
1260 }
1261 n++;
1262 ap1++;
1263 ap2++;
1264 }
1265 if (*ap1 == *ap2) {
1266 tp1 = TP(sym1->s_type);
1267 tp2 = TP(sym->s_type);
1268 if (tp1->t_vararg == tp2->t_vararg)
1269 continue;
1270 if (tp2->t_vararg &&
1271 sym1->s_va && sym1->s_nva == n && !sflag) {
1272 continue;
1273 }
1274 }
1275 /* %s: variable # of args declared\t%s :: %s */
1276 pos1 = xstrdup(mkpos(&sym1->s_pos));
1277 msg(12, hte->h_name, pos1, mkpos(&sym->s_pos));
1278 free(pos1);
1279 }
1280 }
1281
1282
1283 /*
1284 * Check compatibility of two types. Returns 1 if types are compatible,
1285 * otherwise 0.
1286 *
1287 * ignqual if set, ignore qualifiers of outhermost type; used for
1288 * function arguments
1289 * promote if set, promote left type before comparision; used for
1290 * comparisions of arguments with parameters of old style
1291 * definitions
1292 * asgn left indirected type must have at least the same qualifiers
1293 * like right indirected type (for assignments and function
1294 * arguments)
1295 * *warn set to 1 if an old style declaration was compared with
1296 * an incompatible prototype declaration
1297 */
1298 static int
1299 eqtype(tp1, tp2, ignqual, promot, asgn, warn)
1300 type_t *tp1, *tp2;
1301 int ignqual, promot, asgn, *warn;
1302 {
1303 tspec_t t, to;
1304 int indir;
1305
1306 to = NOTSPEC;
1307 indir = 0;
1308
1309 while (tp1 != NULL && tp2 != NULL) {
1310
1311 t = tp1->t_tspec;
1312 if (promot) {
1313 if (t == FLOAT) {
1314 t = DOUBLE;
1315 } else if (t == CHAR || t == SCHAR) {
1316 t = INT;
1317 } else if (t == UCHAR) {
1318 t = tflag ? UINT : INT;
1319 } else if (t == SHORT) {
1320 t = INT;
1321 } else if (t == USHORT) {
1322 /* CONSTCOND */
1323 t = INT_MAX < USHRT_MAX || tflag ? UINT : INT;
1324 }
1325 }
1326
1327 if (asgn && to == PTR) {
1328 if (indir == 1 && (t == VOID || tp2->t_tspec == VOID))
1329 return (1);
1330 }
1331
1332 if (t != tp2->t_tspec) {
1333 /*
1334 * Give pointer to types which differ only in
1335 * signedness a chance if not sflag and not hflag.
1336 */
1337 if (sflag || hflag || to != PTR)
1338 return (0);
1339 if (styp(t) != styp(tp2->t_tspec))
1340 return (0);
1341 }
1342
1343 if (tp1->t_isenum && tp2->t_isenum) {
1344 if (tp1->t_istag && tp2->t_istag) {
1345 return (tp1->t_tag == tp2->t_tag);
1346 } else if (tp1->t_istynam && tp2->t_istynam) {
1347 return (tp1->t_tynam == tp2->t_tynam);
1348 } else if (tp1->t_isuniqpos && tp2->t_isuniqpos) {
1349 return (tp1->t_uniqpos.p_line ==
1350 tp2->t_uniqpos.p_line &&
1351 tp1->t_uniqpos.p_file ==
1352 tp2->t_uniqpos.p_file &&
1353 tp1->t_uniqpos.p_uniq ==
1354 tp2->t_uniqpos.p_uniq);
1355 } else {
1356 return (0);
1357 }
1358 }
1359
1360 /*
1361 * XXX Handle combinations of enum and int if eflag is set.
1362 * But note: enum and 0 should be allowed.
1363 */
1364
1365 if (asgn && indir == 1) {
1366 if (!tp1->t_const && tp2->t_const)
1367 return (0);
1368 if (!tp1->t_volatile && tp2->t_volatile)
1369 return (0);
1370 } else if (!ignqual && !tflag) {
1371 if (tp1->t_const != tp2->t_const)
1372 return (0);
1373 if (tp1->t_const != tp2->t_const)
1374 return (0);
1375 }
1376
1377 if (t == STRUCT || t == UNION) {
1378 if (tp1->t_istag && tp2->t_istag) {
1379 return (tp1->t_tag == tp2->t_tag);
1380 } else if (tp1->t_istynam && tp2->t_istynam) {
1381 return (tp1->t_tynam == tp2->t_tynam);
1382 } else if (tp1->t_isuniqpos && tp2->t_isuniqpos) {
1383 return (tp1->t_uniqpos.p_line ==
1384 tp2->t_uniqpos.p_line &&
1385 tp1->t_uniqpos.p_file ==
1386 tp2->t_uniqpos.p_file &&
1387 tp1->t_uniqpos.p_uniq ==
1388 tp2->t_uniqpos.p_uniq);
1389 } else {
1390 return (0);
1391 }
1392 }
1393
1394 if (t == ARRAY && tp1->t_dim != tp2->t_dim) {
1395 if (tp1->t_dim != 0 && tp2->t_dim != 0)
1396 return (0);
1397 }
1398
1399 if (t == FUNC) {
1400 if (tp1->t_proto && tp2->t_proto) {
1401 if (!eqargs(tp1, tp2, warn))
1402 return (0);
1403 } else if (tp1->t_proto) {
1404 if (!mnoarg(tp1, warn))
1405 return (0);
1406 } else if (tp2->t_proto) {
1407 if (!mnoarg(tp2, warn))
1408 return (0);
1409 }
1410 }
1411
1412 tp1 = tp1->t_subt;
1413 tp2 = tp2->t_subt;
1414 ignqual = promot = 0;
1415 to = t;
1416 indir++;
1417
1418 }
1419
1420 return (tp1 == tp2);
1421 }
1422
1423 /*
1424 * Compares arguments of two prototypes
1425 */
1426 static int
1427 eqargs(tp1, tp2, warn)
1428 type_t *tp1, *tp2;
1429 int *warn;
1430 {
1431 type_t **a1, **a2;
1432
1433 if (tp1->t_vararg != tp2->t_vararg)
1434 return (0);
1435
1436 a1 = tp1->t_args;
1437 a2 = tp2->t_args;
1438
1439 while (*a1 != NULL && *a2 != NULL) {
1440
1441 if (eqtype(*a1, *a2, 1, 0, 0, warn) == 0)
1442 return (0);
1443
1444 a1++;
1445 a2++;
1446
1447 }
1448
1449 return (*a1 == *a2);
1450 }
1451
1452 /*
1453 * mnoarg() (matches functions with no argument type information)
1454 * returns 1 if all parameters of a prototype are compatible with
1455 * and old style function declaration.
1456 * This is the case if following conditions are met:
1457 * 1. the prototype must have a fixed number of parameters
1458 * 2. no parameter is of type float
1459 * 3. no parameter is converted to another type if integer promotion
1460 * is applied on it
1461 */
1462 static int
1463 mnoarg(tp, warn)
1464 type_t *tp;
1465 int *warn;
1466 {
1467 type_t **arg;
1468 tspec_t t;
1469
1470 if (tp->t_vararg && warn != NULL)
1471 *warn = 1;
1472 for (arg = tp->t_args; *arg != NULL; arg++) {
1473 if ((t = (*arg)->t_tspec) == FLOAT)
1474 return (0);
1475 if (t == CHAR || t == SCHAR || t == UCHAR)
1476 return (0);
1477 if (t == SHORT || t == USHORT)
1478 return (0);
1479 }
1480 return (1);
1481 }
1482
1483