Sun Jan 3 17:42:45 2021 UTC ()
lint: let gnuism and c99ism return void instead of int

The return value was only used in a single case.  Duplicating the
condition for printing a message is ok in that case, since it makes all
other places in the code simpler.

The occasional "(void)" or "msg = " before the function call had hidden
the calls from check-msgs.lua, which didn't check the message texts in
such cases.


(rillig)
diff -r1.105 -r1.106 src/usr.bin/xlint/lint1/decl.c
diff -r1.62 -r1.63 src/usr.bin/xlint/lint1/err.c
diff -r1.44 -r1.45 src/usr.bin/xlint/lint1/externs1.h
diff -r1.57 -r1.58 src/usr.bin/xlint/lint1/init.c
diff -r1.110 -r1.111 src/usr.bin/xlint/lint1/scan.l
diff -r1.117 -r1.118 src/usr.bin/xlint/lint1/tree.c

cvs diff -r1.105 -r1.106 src/usr.bin/xlint/lint1/decl.c (expand / switch to unified diff)

--- src/usr.bin/xlint/lint1/decl.c 2021/01/03 17:11:19 1.105
+++ src/usr.bin/xlint/lint1/decl.c 2021/01/03 17:42:45 1.106
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: decl.c,v 1.105 2021/01/03 17:11:19 rillig Exp $ */ 1/* $NetBSD: decl.c,v 1.106 2021/01/03 17:42:45 rillig Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. 4 * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
5 * Copyright (c) 1994, 1995 Jochen Pohl 5 * Copyright (c) 1994, 1995 Jochen Pohl
6 * All Rights Reserved. 6 * All Rights Reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -28,27 +28,27 @@ @@ -28,27 +28,27 @@
28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 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 29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 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 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. 32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */ 33 */
34 34
35#if HAVE_NBTOOL_CONFIG_H 35#if HAVE_NBTOOL_CONFIG_H
36#include "nbtool_config.h" 36#include "nbtool_config.h"
37#endif 37#endif
38 38
39#include <sys/cdefs.h> 39#include <sys/cdefs.h>
40#if defined(__RCSID) && !defined(lint) 40#if defined(__RCSID) && !defined(lint)
41__RCSID("$NetBSD: decl.c,v 1.105 2021/01/03 17:11:19 rillig Exp $"); 41__RCSID("$NetBSD: decl.c,v 1.106 2021/01/03 17:42:45 rillig Exp $");
42#endif 42#endif
43 43
44#include <sys/param.h> 44#include <sys/param.h>
45#include <limits.h> 45#include <limits.h>
46#include <stdlib.h> 46#include <stdlib.h>
47#include <string.h> 47#include <string.h>
48 48
49#include "lint1.h" 49#include "lint1.h"
50 50
51const char *unnamed = "<unnamed>"; 51const char *unnamed = "<unnamed>";
52 52
53/* shared type structures for arithmtic types and void */ 53/* shared type structures for arithmtic types and void */
54static type_t *typetab; 54static type_t *typetab;
@@ -307,27 +307,27 @@ add_type(type_t *tp) @@ -307,27 +307,27 @@ add_type(type_t *tp)
307 /* invalid type for _Complex */ 307 /* invalid type for _Complex */
308 error(308); 308 error(308);
309 t = DCOMPLEX; /* just as a fallback */ 309 t = DCOMPLEX; /* just as a fallback */
310 } 310 }
311 dcs->d_cmod = NOTSPEC; 311 dcs->d_cmod = NOTSPEC;
312 } 312 }
313 313
314 if (t == LONG && dcs->d_lmod == LONG) { 314 if (t == LONG && dcs->d_lmod == LONG) {
315 /* "long long" or "long ... long" */ 315 /* "long long" or "long ... long" */
316 t = QUAD; 316 t = QUAD;
317 dcs->d_lmod = NOTSPEC; 317 dcs->d_lmod = NOTSPEC;
318 if (!quadflg) 318 if (!quadflg)
319 /* %s C does not support 'long long' */ 319 /* %s C does not support 'long long' */
320 (void)c99ism(265, tflag ? "traditional" : "c89"); 320 c99ism(265, tflag ? "traditional" : "c89");
321 } 321 }
322 322
323 if (dcs->d_type != NULL && dcs->d_type->t_typedef) { 323 if (dcs->d_type != NULL && dcs->d_type->t_typedef) {
324 /* something like "typedef int a; a long ..." */ 324 /* something like "typedef int a; a long ..." */
325 dcs->d_type = tdeferr(dcs->d_type, t); 325 dcs->d_type = tdeferr(dcs->d_type, t);
326 return; 326 return;
327 } 327 }
328 328
329 /* now it can be only a combination of arithmetic types and void */ 329 /* now it can be only a combination of arithmetic types and void */
330 if (t == SIGNED || t == UNSIGN) { 330 if (t == SIGNED || t == UNSIGN) {
331 /* remember specifiers "signed" & "unsigned" in dcs->d_smod */ 331 /* remember specifiers "signed" & "unsigned" in dcs->d_smod */
332 if (dcs->d_smod != NOTSPEC) 332 if (dcs->d_smod != NOTSPEC)
333 /* 333 /*
@@ -1768,28 +1768,28 @@ complete_tag_struct_or_union(type_t *tp, @@ -1768,28 +1768,28 @@ complete_tag_struct_or_union(type_t *tp,
1768 setcomplete(tp, 1); 1768 setcomplete(tp, 1);
1769 1769
1770 t = tp->t_tspec; 1770 t = tp->t_tspec;
1771 align(dcs->d_stralign, 0); 1771 align(dcs->d_stralign, 0);
1772 sp = tp->t_str; 1772 sp = tp->t_str;
1773 sp->align = dcs->d_stralign; 1773 sp->align = dcs->d_stralign;
1774 sp->memb = fmem; 1774 sp->memb = fmem;
1775 if (tp->t_ispacked) 1775 if (tp->t_ispacked)
1776 setpackedsize(tp); 1776 setpackedsize(tp);
1777 else 1777 else
1778 sp->size = dcs->d_offset; 1778 sp->size = dcs->d_offset;
1779 1779
1780 if (sp->size == 0) { 1780 if (sp->size == 0) {
1781 /* zero sized %s */ 1781 /* zero sized %s is a C9X feature */
1782 (void)c99ism(47, ttab[t].tt_name); 1782 c99ism(47, ttab[t].tt_name);
1783 } 1783 }
1784 1784
1785 n = 0; 1785 n = 0;
1786 for (mem = fmem; mem != NULL; mem = mem->s_next) { 1786 for (mem = fmem; mem != NULL; mem = mem->s_next) {
1787 /* bind anonymous members to the structure */ 1787 /* bind anonymous members to the structure */
1788 if (mem->s_styp == NULL) { 1788 if (mem->s_styp == NULL) {
1789 mem->s_styp = sp; 1789 mem->s_styp = sp;
1790 if (mem->s_type->t_isfield) { 1790 if (mem->s_type->t_isfield) {
1791 sp->size += bitfieldsize(&mem); 1791 sp->size += bitfieldsize(&mem);
1792 if (mem == NULL) 1792 if (mem == NULL)
1793 break; 1793 break;
1794 } 1794 }
1795 sp->size += tsize(mem->s_type); 1795 sp->size += tsize(mem->s_type);
@@ -2521,27 +2521,28 @@ check_prototype_declaration(sym_t *arg,  @@ -2521,27 +2521,28 @@ check_prototype_declaration(sym_t *arg,
2521{ 2521{
2522 type_t *tp, *ptp; 2522 type_t *tp, *ptp;
2523 int dowarn, msg; 2523 int dowarn, msg;
2524 2524
2525 tp = arg->s_type; 2525 tp = arg->s_type;
2526 ptp = parg->s_type; 2526 ptp = parg->s_type;
2527 2527
2528 msg = 0; 2528 msg = 0;
2529 dowarn = 0; 2529 dowarn = 0;
2530 2530
2531 if (!eqtype(tp, ptp, 1, 1, &dowarn)) { 2531 if (!eqtype(tp, ptp, 1, 1, &dowarn)) {
2532 if (eqtype(tp, ptp, 1, 0, &dowarn)) { 2532 if (eqtype(tp, ptp, 1, 0, &dowarn)) {
2533 /* type does not match prototype: %s */ 2533 /* type does not match prototype: %s */
2534 msg = gnuism(58, arg->s_name); 2534 gnuism(58, arg->s_name);
 2535 msg = sflag || !gflag;
2535 } else { 2536 } else {
2536 /* type does not match prototype: %s */ 2537 /* type does not match prototype: %s */
2537 error(58, arg->s_name); 2538 error(58, arg->s_name);
2538 msg = 1; 2539 msg = 1;
2539 } 2540 }
2540 } else if (dowarn) { 2541 } else if (dowarn) {
2541 if (sflag) 2542 if (sflag)
2542 /* type does not match prototype: %s */ 2543 /* type does not match prototype: %s */
2543 error(58, arg->s_name); 2544 error(58, arg->s_name);
2544 else 2545 else
2545 /* type does not match prototype: %s */ 2546 /* type does not match prototype: %s */
2546 warning(58, arg->s_name); 2547 warning(58, arg->s_name);
2547 msg = 1; 2548 msg = 1;

cvs diff -r1.62 -r1.63 src/usr.bin/xlint/lint1/err.c (expand / switch to unified diff)

--- src/usr.bin/xlint/lint1/err.c 2021/01/03 16:59:59 1.62
+++ src/usr.bin/xlint/lint1/err.c 2021/01/03 17:42:45 1.63
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: err.c,v 1.62 2021/01/03 16:59:59 rillig Exp $ */ 1/* $NetBSD: err.c,v 1.63 2021/01/03 17:42:45 rillig Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1994, 1995 Jochen Pohl 4 * Copyright (c) 1994, 1995 Jochen Pohl
5 * All Rights Reserved. 5 * All Rights Reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -27,27 +27,27 @@ @@ -27,27 +27,27 @@
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */ 32 */
33 33
34#if HAVE_NBTOOL_CONFIG_H 34#if HAVE_NBTOOL_CONFIG_H
35#include "nbtool_config.h" 35#include "nbtool_config.h"
36#endif 36#endif
37 37
38#include <sys/cdefs.h> 38#include <sys/cdefs.h>
39#if defined(__RCSID) && !defined(lint) 39#if defined(__RCSID) && !defined(lint)
40__RCSID("$NetBSD: err.c,v 1.62 2021/01/03 16:59:59 rillig Exp $"); 40__RCSID("$NetBSD: err.c,v 1.63 2021/01/03 17:42:45 rillig Exp $");
41#endif 41#endif
42 42
43#include <sys/types.h> 43#include <sys/types.h>
44#include <stdarg.h> 44#include <stdarg.h>
45#include <stdlib.h> 45#include <stdlib.h>
46 46
47#include "lint1.h" 47#include "lint1.h"
48 48
49/* number of errors found */ 49/* number of errors found */
50int nerr; 50int nerr;
51 51
52/* number of syntax errors */ 52/* number of syntax errors */
53int sytxerr; 53int sytxerr;
@@ -524,54 +524,41 @@ message(int n, ...) @@ -524,54 +524,41 @@ message(int n, ...)
524 fn = lbasename(curr_pos.p_file); 524 fn = lbasename(curr_pos.p_file);
525 (void)printf("%s(%d): ", fn, curr_pos.p_line); 525 (void)printf("%s(%d): ", fn, curr_pos.p_line);
526 (void)vprintf(msgs[n], ap); 526 (void)vprintf(msgs[n], ap);
527 (void)printf(" [%d]\n", n); 527 (void)printf(" [%d]\n", n);
528 va_end(ap); 528 va_end(ap);
529} 529}
530 530
531/* 531/*
532 * XXX I think the logic is possibly somewhat screwed up here. The 532 * XXX I think the logic is possibly somewhat screwed up here. The
533 * question is, how do we want to interpret the -s and -S flags going 533 * question is, how do we want to interpret the -s and -S flags going
534 * forward? We need to answer that and then we can fix this to be 534 * forward? We need to answer that and then we can fix this to be
535 * "right"... [perry, 2 Nov 2002] 535 * "right"... [perry, 2 Nov 2002]
536*/ 536*/
537int 537void
538c99ism(int n, ...) 538c99ism(int n, ...)
539{ 539{
540 va_list ap; 540 va_list ap;
541 int msg; 541 bool extensions_ok = Sflag || gflag;
542 542
543 va_start(ap, n); 543 va_start(ap, n);
544 if (sflag && !(Sflag || gflag)) { 544 if (sflag && !extensions_ok) {
545 verror(n, ap); 545 verror(n, ap);
546 msg = 1; 546 } else if (sflag || !extensions_ok) {
547 } else if (!sflag && (Sflag || gflag)) { 
548 msg = 0; 
549 } else { 
550 vwarning(n, ap); 547 vwarning(n, ap);
551 msg = 1; 
552 } 548 }
553 va_end(ap); 549 va_end(ap);
554 
555 return msg; 
556} 550}
557 551
558int 552void
559gnuism(int n, ...) 553gnuism(int n, ...)
560{ 554{
561 va_list ap; 555 va_list ap;
562 int msg; 
563 556
564 va_start(ap, n); 557 va_start(ap, n);
565 if (sflag && !gflag) { 558 if (sflag && !gflag) {
566 verror(n, ap); 559 verror(n, ap);
567 msg = 1; 560 } else if (sflag || !gflag) {
568 } else if (!sflag && gflag) { 
569 msg = 0; 
570 } else { 
571 vwarning(n, ap); 561 vwarning(n, ap);
572 msg = 1; 
573 } 562 }
574 va_end(ap); 563 va_end(ap);
575 
576 return msg; 
577} 564}

cvs diff -r1.44 -r1.45 src/usr.bin/xlint/lint1/externs1.h (expand / switch to unified diff)

--- src/usr.bin/xlint/lint1/externs1.h 2021/01/02 18:44:58 1.44
+++ src/usr.bin/xlint/lint1/externs1.h 2021/01/03 17:42:45 1.45
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: externs1.h,v 1.44 2021/01/02 18:44:58 rillig Exp $ */ 1/* $NetBSD: externs1.h,v 1.45 2021/01/03 17:42:45 rillig Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1994, 1995 Jochen Pohl 4 * Copyright (c) 1994, 1995 Jochen Pohl
5 * All Rights Reserved. 5 * All Rights Reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -113,28 +113,28 @@ extern struct mbl *tsave(void); @@ -113,28 +113,28 @@ extern struct mbl *tsave(void);
113extern void trestor(struct mbl *); 113extern void trestor(struct mbl *);
114 114
115/* 115/*
116 * err.c 116 * err.c
117 */ 117 */
118extern int nerr; 118extern int nerr;
119extern int sytxerr; 119extern int sytxerr;
120extern const char *msgs[]; 120extern const char *msgs[];
121 121
122extern void msglist(void); 122extern void msglist(void);
123extern void error(int, ...); 123extern void error(int, ...);
124extern void warning(int, ...); 124extern void warning(int, ...);
125extern void message(int, ...); 125extern void message(int, ...);
126extern int gnuism(int, ...); 126extern void gnuism(int, ...);
127extern int c99ism(int, ...); 127extern void c99ism(int, ...);
128extern void lerror(const char *, int, const char *, ...) 128extern void lerror(const char *, int, const char *, ...)
129 __attribute__((__noreturn__,__format__(__printf__, 3, 4))); 129 __attribute__((__noreturn__,__format__(__printf__, 3, 4)));
130extern void assert_failed(const char *, int, const char *, const char *) 130extern void assert_failed(const char *, int, const char *, const char *)
131 __attribute__((__noreturn__)); 131 __attribute__((__noreturn__));
132 132
133/* 133/*
134 * decl.c 134 * decl.c
135 */ 135 */
136extern dinfo_t *dcs; 136extern dinfo_t *dcs;
137extern const char *unnamed; 137extern const char *unnamed;
138extern int enumval; 138extern int enumval;
139 139
140extern void initdecl(void); 140extern void initdecl(void);

cvs diff -r1.57 -r1.58 src/usr.bin/xlint/lint1/init.c (expand / switch to unified diff)

--- src/usr.bin/xlint/lint1/init.c 2021/01/02 03:49:25 1.57
+++ src/usr.bin/xlint/lint1/init.c 2021/01/03 17:42:45 1.58
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: init.c,v 1.57 2021/01/02 03:49:25 rillig Exp $ */ 1/* $NetBSD: init.c,v 1.58 2021/01/03 17:42:45 rillig Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1994, 1995 Jochen Pohl 4 * Copyright (c) 1994, 1995 Jochen Pohl
5 * All Rights Reserved. 5 * All Rights Reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -27,27 +27,27 @@ @@ -27,27 +27,27 @@
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */ 32 */
33 33
34#if HAVE_NBTOOL_CONFIG_H 34#if HAVE_NBTOOL_CONFIG_H
35#include "nbtool_config.h" 35#include "nbtool_config.h"
36#endif 36#endif
37 37
38#include <sys/cdefs.h> 38#include <sys/cdefs.h>
39#if defined(__RCSID) && !defined(lint) 39#if defined(__RCSID) && !defined(lint)
40__RCSID("$NetBSD: init.c,v 1.57 2021/01/02 03:49:25 rillig Exp $"); 40__RCSID("$NetBSD: init.c,v 1.58 2021/01/03 17:42:45 rillig Exp $");
41#endif 41#endif
42 42
43#include <stdlib.h> 43#include <stdlib.h>
44#include <string.h> 44#include <string.h>
45 45
46#include "lint1.h" 46#include "lint1.h"
47 47
48 48
49/* 49/*
50 * Type of stack which is used for initialisation of aggregate types. 50 * Type of stack which is used for initialisation of aggregate types.
51 * 51 *
52 * XXX: Since C99, a stack is an inappropriate data structure for modelling 52 * XXX: Since C99, a stack is an inappropriate data structure for modelling
53 * an initialization, since the designators don't have to be listed in a 53 * an initialization, since the designators don't have to be listed in a
@@ -642,27 +642,27 @@ mkinit(tnode_t *tn) @@ -642,27 +642,27 @@ mkinit(tnode_t *tn)
642 /* bit-field initialisation is illegal in trad. C */ 642 /* bit-field initialisation is illegal in trad. C */
643 warning(186); 643 warning(186);
644 } 644 }
645 645
646 if (lt != rt || (initstk->i_type->t_isfield && tn->tn_op == CON)) 646 if (lt != rt || (initstk->i_type->t_isfield && tn->tn_op == CON))
647 tn = convert(INIT, 0, initstk->i_type, tn); 647 tn = convert(INIT, 0, initstk->i_type, tn);
648 648
649 if (tn != NULL && tn->tn_op != CON) { 649 if (tn != NULL && tn->tn_op != CON) {
650 sym = NULL; 650 sym = NULL;
651 offs = 0; 651 offs = 0;
652 if (conaddr(tn, &sym, &offs) == -1) { 652 if (conaddr(tn, &sym, &offs) == -1) {
653 if (sc == AUTO || sc == REG) { 653 if (sc == AUTO || sc == REG) {
654 /* non-constant initializer */ 654 /* non-constant initializer */
655 (void)c99ism(177); 655 c99ism(177);
656 } else { 656 } else {
657 /* non-constant initializer */ 657 /* non-constant initializer */
658 error(177); 658 error(177);
659 } 659 }
660 } 660 }
661 } 661 }
662} 662}
663 663
664 664
665static int 665static int
666initstack_string(tnode_t *tn) 666initstack_string(tnode_t *tn)
667{ 667{
668 tspec_t t; 668 tspec_t t;

cvs diff -r1.110 -r1.111 src/usr.bin/xlint/lint1/scan.l (expand / switch to unified diff)

--- src/usr.bin/xlint/lint1/scan.l 2021/01/02 01:06:15 1.110
+++ src/usr.bin/xlint/lint1/scan.l 2021/01/03 17:42:45 1.111
@@ -1,15 +1,15 @@ @@ -1,15 +1,15 @@
1%{ 1%{
2/* $NetBSD: scan.l,v 1.110 2021/01/02 01:06:15 rillig Exp $ */ 2/* $NetBSD: scan.l,v 1.111 2021/01/03 17:42:45 rillig Exp $ */
3 3
4/* 4/*
5 * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. 5 * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
6 * Copyright (c) 1994, 1995 Jochen Pohl 6 * Copyright (c) 1994, 1995 Jochen Pohl
7 * All Rights Reserved. 7 * All Rights Reserved.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the 15 * notice, this list of conditions and the following disclaimer in the
@@ -25,27 +25,27 @@ @@ -25,27 +25,27 @@
25 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 25 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 26 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 27 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
28 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 28 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */ 34 */
35 35
36#include <sys/cdefs.h> 36#include <sys/cdefs.h>
37#if defined(__RCSID) && !defined(lint) 37#if defined(__RCSID) && !defined(lint)
38__RCSID("$NetBSD: scan.l,v 1.110 2021/01/02 01:06:15 rillig Exp $"); 38__RCSID("$NetBSD: scan.l,v 1.111 2021/01/03 17:42:45 rillig Exp $");
39#endif 39#endif
40 40
41#include <ctype.h> 41#include <ctype.h>
42#include <errno.h> 42#include <errno.h>
43#include <float.h> 43#include <float.h>
44#include <limits.h> 44#include <limits.h>
45#include <math.h> 45#include <math.h>
46#include <stdlib.h> 46#include <stdlib.h>
47#include <string.h> 47#include <string.h>
48 48
49#include "lint1.h" 49#include "lint1.h"
50#include "cgram.h" 50#include "cgram.h"
51 51
@@ -1306,28 +1306,28 @@ comment(void) @@ -1306,28 +1306,28 @@ comment(void)
1306 eoc = 1; 1306 eoc = 1;
1307 } 1307 }
1308} 1308}
1309 1309
1310/* 1310/*
1311 * Handle // style comments 1311 * Handle // style comments
1312 */ 1312 */
1313static void 1313static void
1314slashslashcomment(void) 1314slashslashcomment(void)
1315{ 1315{
1316 int c; 1316 int c;
1317 1317
1318 if (!Sflag && !gflag) 1318 if (!Sflag && !gflag)
1319 /* // comments only supported in C99 */ 1319 /* %s C does not support // comments */
1320 (void)gnuism(312, tflag ? "traditional" : "ANSI"); 1320 gnuism(312, tflag ? "traditional" : "ANSI");
1321 1321
1322 while ((c = inpc()) != EOF && c != '\n') 1322 while ((c = inpc()) != EOF && c != '\n')
1323 continue; 1323 continue;
1324} 1324}
1325 1325
1326/* 1326/*
1327 * Clear flags for lint comments LINTED, LONGLONG and CONSTCOND. 1327 * Clear flags for lint comments LINTED, LONGLONG and CONSTCOND.
1328 * clrwflgs() is called after function definitions and global and 1328 * clrwflgs() is called after function definitions and global and
1329 * local declarations and definitions. It is also called between 1329 * local declarations and definitions. It is also called between
1330 * the controlling expression and the body of control statements 1330 * the controlling expression and the body of control statements
1331 * (if, switch, for, while). 1331 * (if, switch, for, while).
1332 */ 1332 */
1333void 1333void

cvs diff -r1.117 -r1.118 src/usr.bin/xlint/lint1/tree.c (expand / switch to unified diff)

--- src/usr.bin/xlint/lint1/tree.c 2021/01/03 15:51:16 1.117
+++ src/usr.bin/xlint/lint1/tree.c 2021/01/03 17:42:45 1.118
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: tree.c,v 1.117 2021/01/03 15:51:16 rillig Exp $ */ 1/* $NetBSD: tree.c,v 1.118 2021/01/03 17:42:45 rillig Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1994, 1995 Jochen Pohl 4 * Copyright (c) 1994, 1995 Jochen Pohl
5 * All Rights Reserved. 5 * All Rights Reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -27,27 +27,27 @@ @@ -27,27 +27,27 @@
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */ 32 */
33 33
34#if HAVE_NBTOOL_CONFIG_H 34#if HAVE_NBTOOL_CONFIG_H
35#include "nbtool_config.h" 35#include "nbtool_config.h"
36#endif 36#endif
37 37
38#include <sys/cdefs.h> 38#include <sys/cdefs.h>
39#if defined(__RCSID) && !defined(lint) 39#if defined(__RCSID) && !defined(lint)
40__RCSID("$NetBSD: tree.c,v 1.117 2021/01/03 15:51:16 rillig Exp $"); 40__RCSID("$NetBSD: tree.c,v 1.118 2021/01/03 17:42:45 rillig Exp $");
41#endif 41#endif
42 42
43#include <float.h> 43#include <float.h>
44#include <limits.h> 44#include <limits.h>
45#include <math.h> 45#include <math.h>
46#include <signal.h> 46#include <signal.h>
47#include <stdlib.h> 47#include <stdlib.h>
48#include <string.h> 48#include <string.h>
49 49
50#include "lint1.h" 50#include "lint1.h"
51#include "cgram.h" 51#include "cgram.h"
52#include "externs1.h" 52#include "externs1.h"
53 53
@@ -650,29 +650,29 @@ build(op_t op, tnode_t *ln, tnode_t *rn) @@ -650,29 +650,29 @@ build(op_t op, tnode_t *ln, tnode_t *rn)
650 * Lvalues are converted to rvalues. 650 * Lvalues are converted to rvalues.
651 */ 651 */
652tnode_t * 652tnode_t *
653cconv(tnode_t *tn) 653cconv(tnode_t *tn)
654{ 654{
655 type_t *tp; 655 type_t *tp;
656 656
657 /* 657 /*
658 * Array-lvalue (array of type T) is converted into rvalue 658 * Array-lvalue (array of type T) is converted into rvalue
659 * (pointer to type T) 659 * (pointer to type T)
660 */ 660 */
661 if (tn->tn_type->t_tspec == ARRAY) { 661 if (tn->tn_type->t_tspec == ARRAY) {
662 if (!tn->tn_lvalue) { 662 if (!tn->tn_lvalue) {
663 /* %soperand of '%s' must be lvalue */ 
664 /* XXX print correct operator */ 663 /* XXX print correct operator */
665 (void)gnuism(114, "", modtab[AMPER].m_name); 664 /* %soperand of '%s' must be lvalue */
 665 gnuism(114, "", modtab[AMPER].m_name);
666 } 666 }
667 tn = new_tnode(AMPER, tincref(tn->tn_type->t_subt, PTR), 667 tn = new_tnode(AMPER, tincref(tn->tn_type->t_subt, PTR),
668 tn, NULL); 668 tn, NULL);
669 } 669 }
670 670
671 /* 671 /*
672 * Expression of type function (function with return value of type T) 672 * Expression of type function (function with return value of type T)
673 * in rvalue-expression (pointer to function with return value 673 * in rvalue-expression (pointer to function with return value
674 * of type T) 674 * of type T)
675 */ 675 */
676 if (tn->tn_type->t_tspec == FUNC) 676 if (tn->tn_type->t_tspec == FUNC)
677 tn = build_ampersand(tn, 1); 677 tn = build_ampersand(tn, 1);
678 678
@@ -2621,27 +2621,27 @@ plength(type_t *tp) @@ -2621,27 +2621,27 @@ plength(type_t *tp)
2621 2621
2622 while (tp->t_tspec == ARRAY) { 2622 while (tp->t_tspec == ARRAY) {
2623 elem *= tp->t_dim; 2623 elem *= tp->t_dim;
2624 tp = tp->t_subt; 2624 tp = tp->t_subt;
2625 } 2625 }
2626 2626
2627 switch (tp->t_tspec) { 2627 switch (tp->t_tspec) {
2628 case FUNC: 2628 case FUNC:
2629 /* pointer to function is not allowed here */ 2629 /* pointer to function is not allowed here */
2630 error(110); 2630 error(110);
2631 break; 2631 break;
2632 case VOID: 2632 case VOID:
2633 /* cannot do pointer arithmetic on operand of ... */ 2633 /* cannot do pointer arithmetic on operand of ... */
2634 (void)gnuism(136); 2634 gnuism(136);
2635 break; 2635 break;
2636 case STRUCT: 2636 case STRUCT:
2637 case UNION: 2637 case UNION:
2638 if ((elsz = tp->t_str->size) == 0) 2638 if ((elsz = tp->t_str->size) == 0)
2639 /* cannot do pointer arithmetic on operand of ... */ 2639 /* cannot do pointer arithmetic on operand of ... */
2640 error(136); 2640 error(136);
2641 break; 2641 break;
2642 case ENUM: 2642 case ENUM:
2643 if (incompl(tp)) { 2643 if (incompl(tp)) {
2644 /* cannot do pointer arithmetic on operand of ... */ 2644 /* cannot do pointer arithmetic on operand of ... */
2645 warning(136); 2645 warning(136);
2646 } 2646 }
2647 /* FALLTHROUGH */ 2647 /* FALLTHROUGH */