Module Name: src
Committed By: christos
Date: Fri Apr 19 17:43:06 UTC 2013
Modified Files:
src/usr.bin/xlint/lint1: cgram.y decl.c err.c externs1.h func.c lint1.h
main1.c scan.l
Log Message:
Allow linted comments to take an argument that defines which error to suppress.
To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/usr.bin/xlint/lint1/cgram.y
cvs rdiff -u -r1.55 -r1.56 src/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.45 -r1.46 src/usr.bin/xlint/lint1/err.c
cvs rdiff -u -r1.30 -r1.31 src/usr.bin/xlint/lint1/externs1.h
cvs rdiff -u -r1.24 -r1.25 src/usr.bin/xlint/lint1/func.c
cvs rdiff -u -r1.26 -r1.27 src/usr.bin/xlint/lint1/lint1.h
cvs rdiff -u -r1.20 -r1.21 src/usr.bin/xlint/lint1/main1.c
cvs rdiff -u -r1.50 -r1.51 src/usr.bin/xlint/lint1/scan.l
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/xlint/lint1/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.54 src/usr.bin/xlint/lint1/cgram.y:1.55
--- src/usr.bin/xlint/lint1/cgram.y:1.54 Tue Mar 27 15:24:03 2012
+++ src/usr.bin/xlint/lint1/cgram.y Fri Apr 19 13:43:05 2013
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: cgram.y,v 1.54 2012/03/27 19:24:03 christos Exp $ */
+/* $NetBSD: cgram.y,v 1.55 2013/04/19 17:43:05 christos Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -35,7 +35,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.54 2012/03/27 19:24:03 christos Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.55 2013/04/19 17:43:05 christos Exp $");
#endif
#include <stdlib.h>
@@ -63,7 +63,7 @@ int mblklev;
* Save the no-warns state and restore it to avoid the problem where
* if (expr) { stmt } / * NOLINT * / stmt;
*/
-static int onowarn = -1;
+static int olwarn = LWARN_BAD;
static int toicon(tnode_t *, int);
static void idecl(sym_t *, int, sbuf_t *);
@@ -76,34 +76,34 @@ static inline void CLRWFLGS(const char *
printf("%s, %d: clear flags %s %zu\n", curr_pos.p_file,
curr_pos.p_line, file, line);
clrwflgs();
- onowarn = -1;
+ olwarn = LWARN_BAD;
}
static inline void SAVE(const char *file, size_t line);
static inline void SAVE(const char *file, size_t line)
{
- if (onowarn != -1)
+ if (olwarn != LWARN_BAD)
abort();
printf("%s, %d: save flags %s %zu = %d\n", curr_pos.p_file,
- curr_pos.p_line, file, line, nowarn);
- onowarn = nowarn;
+ curr_pos.p_line, file, line, lwarn);
+ olwarn = lwarn;
}
static inline void RESTORE(const char *file, size_t line);
static inline void RESTORE(const char *file, size_t line)
{
- if (onowarn != -1) {
- nowarn = onowarn;
+ if (olwarn != LWARN_BAD) {
+ lwarn = olwarn;
printf("%s, %d: restore flags %s %zu = %d\n", curr_pos.p_file,
- curr_pos.p_line, file, line, nowarn);
- onowarn = -1;
+ curr_pos.p_line, file, line, lwarn);
+ olwarn = LWARN_BAD;
} else
CLRWFLGS(file, line);
}
#else
-#define CLRWFLGS(f, l) clrwflgs(), onowarn = -1
-#define SAVE(f, l) onowarn = nowarn
-#define RESTORE(f, l) (void)(onowarn == -1 ? (clrwflgs(), 0) : (nowarn = onowarn))
+#define CLRWFLGS(f, l) clrwflgs(), olwarn = LWARN_BAD
+#define SAVE(f, l) olwarn = lwarn
+#define RESTORE(f, l) (void)(olwarn == LWARN_BAD ? (clrwflgs(), 0) : (lwarn = olwarn))
#endif
%}
@@ -373,7 +373,7 @@ func_def:
funcdef($1);
blklev++;
pushdecl(ARG);
- if (nowarn)
+ if (lwarn == LWARN_NONE)
$1->s_used = 1;
} opt_arg_declaration_list {
popdecl();
Index: src/usr.bin/xlint/lint1/decl.c
diff -u src/usr.bin/xlint/lint1/decl.c:1.55 src/usr.bin/xlint/lint1/decl.c:1.56
--- src/usr.bin/xlint/lint1/decl.c:1.55 Sat Feb 16 20:26:19 2013
+++ src/usr.bin/xlint/lint1/decl.c Fri Apr 19 13:43:05 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.55 2013/02/17 01:26:19 christos Exp $ */
+/* $NetBSD: decl.c,v 1.56 2013/04/19 17:43:05 christos Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: decl.c,v 1.55 2013/02/17 01:26:19 christos Exp $");
+__RCSID("$NetBSD: decl.c,v 1.56 2013/04/19 17:43:05 christos Exp $");
#endif
#include <sys/param.h>
@@ -2876,21 +2876,22 @@ void
chkusage(dinfo_t *di)
{
sym_t *sym;
- int mknowarn;
+ int mklwarn;
/* for this warnings LINTED has no effect */
- mknowarn = nowarn;
- nowarn = 0;
+ mklwarn = lwarn;
+ lwarn = LWARN_ALL;
#ifdef DEBUG
- printf("%s, %d: >temp nowarn = 0\n", curr_pos.p_file, curr_pos.p_line);
+ printf("%s, %d: >temp lwarn = %d\n", curr_pos.p_file, curr_pos.p_line,
+ lwarn);
#endif
for (sym = di->d_dlsyms; sym != NULL; sym = sym->s_dlnxt)
chkusg1(di->d_asm, sym);
- nowarn = mknowarn;
+ lwarn = mklwarn;
#ifdef DEBUG
- printf("%s, %d: <temp nowarn = %d\n", curr_pos.p_file, curr_pos.p_line,
- nowarn);
+ printf("%s, %d: <temp lwarn = %d\n", curr_pos.p_file, curr_pos.p_line,
+ lwarn);
#endif
}
Index: src/usr.bin/xlint/lint1/err.c
diff -u src/usr.bin/xlint/lint1/err.c:1.45 src/usr.bin/xlint/lint1/err.c:1.46
--- src/usr.bin/xlint/lint1/err.c:1.45 Fri Apr 20 14:35:28 2012
+++ src/usr.bin/xlint/lint1/err.c Fri Apr 19 13:43:05 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: err.c,v 1.45 2012/04/20 18:35:28 christos Exp $ */
+/* $NetBSD: err.c,v 1.46 2013/04/19 17:43:05 christos Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: err.c,v 1.45 2012/04/20 18:35:28 christos Exp $");
+__RCSID("$NetBSD: err.c,v 1.46 2013/04/19 17:43:05 christos Exp $");
#endif
#include <sys/types.h>
@@ -59,7 +59,7 @@ static void vwarning(int, va_list);
const char *msgs[] = {
- "syntax error: empty declaration", /* 0 */
+ "empty declaration", /* 0 */
"old style declaration; add int", /* 1 */
"empty declaration", /* 2 */
"%s declared in argument declaration list", /* 3 */
@@ -439,14 +439,17 @@ verror( int n, va_list ap)
}
static void
-vwarning( int n, va_list ap)
+vwarning(int n, va_list ap)
{
const char *fn;
if (ERR_ISSET(n, &msgset))
return;
- if (nowarn)
+#ifdef DEBUG
+ printf("%s: lwarn=%d n=%d\n", __func__, lwarn, n);
+#endif
+ if (lwarn == LWARN_NONE || lwarn == n)
/* this warning is suppressed by a LINTED comment */
return;
Index: src/usr.bin/xlint/lint1/externs1.h
diff -u src/usr.bin/xlint/lint1/externs1.h:1.30 src/usr.bin/xlint/lint1/externs1.h:1.31
--- src/usr.bin/xlint/lint1/externs1.h:1.30 Sat Feb 5 12:14:14 2011
+++ src/usr.bin/xlint/lint1/externs1.h Fri Apr 19 13:43:05 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: externs1.h,v 1.30 2011/02/05 17:14:14 christos Exp $ */
+/* $NetBSD: externs1.h,v 1.31 2013/04/19 17:43:05 christos Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -228,7 +228,7 @@ extern int scflstrg;
extern pos_t scflpos;
extern int ccflg;
extern int llibflg;
-extern int nowarn;
+extern int lwarn;
extern int bitfieldtype_ok;
extern int plibflg;
extern int quadflg;
Index: src/usr.bin/xlint/lint1/func.c
diff -u src/usr.bin/xlint/lint1/func.c:1.24 src/usr.bin/xlint/lint1/func.c:1.25
--- src/usr.bin/xlint/lint1/func.c:1.24 Sun Nov 16 02:06:37 2008
+++ src/usr.bin/xlint/lint1/func.c Fri Apr 19 13:43:05 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: func.c,v 1.24 2008/11/16 07:06:37 dholland Exp $ */
+/* $NetBSD: func.c,v 1.25 2013/04/19 17:43:05 christos Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: func.c,v 1.24 2008/11/16 07:06:37 dholland Exp $");
+__RCSID("$NetBSD: func.c,v 1.25 2013/04/19 17:43:05 christos Exp $");
#endif
#include <stdlib.h>
@@ -130,8 +130,12 @@ int llibflg;
/*
* Nonzero if warnings are suppressed by a LINTED directive
+ * LWARN_BAD: error
+ * LWARN_ALL: warnings on
+ * LWARN_NONE: all warnings ignored
+ * 0..n: warning n ignored
*/
-int nowarn;
+int lwarn = LWARN_ALL;
/*
* Nonzero if bitfield type errors are suppressed by a BITFIELDTYPE
@@ -1241,9 +1245,9 @@ linted(int n)
{
#ifdef DEBUG
- printf("%s, %d: nowarn = 1\n", curr_pos.p_file, curr_pos.p_line);
+ printf("%s, %d: lwarn = %d\n", curr_pos.p_file, curr_pos.p_line, n);
#endif
- nowarn = 1;
+ lwarn = n;
}
/*
Index: src/usr.bin/xlint/lint1/lint1.h
diff -u src/usr.bin/xlint/lint1/lint1.h:1.26 src/usr.bin/xlint/lint1/lint1.h:1.27
--- src/usr.bin/xlint/lint1/lint1.h:1.26 Sat Feb 16 20:26:19 2013
+++ src/usr.bin/xlint/lint1/lint1.h Fri Apr 19 13:43:05 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: lint1.h,v 1.26 2013/02/17 01:26:19 christos Exp $ */
+/* $NetBSD: lint1.h,v 1.27 2013/04/19 17:43:05 christos Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -50,6 +50,10 @@
#define WORST_ALIGN(x) (((x) + AVAL) & ~AVAL)
#endif
+#define LWARN_BAD -3
+#define LWARN_ALL -2
+#define LWARN_NONE -1
+
/*
* Describes the position of a declaration or anything else.
*/
Index: src/usr.bin/xlint/lint1/main1.c
diff -u src/usr.bin/xlint/lint1/main1.c:1.20 src/usr.bin/xlint/lint1/main1.c:1.21
--- src/usr.bin/xlint/lint1/main1.c:1.20 Tue Mar 27 15:24:03 2012
+++ src/usr.bin/xlint/lint1/main1.c Fri Apr 19 13:43:05 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: main1.c,v 1.20 2012/03/27 19:24:03 christos Exp $ */
+/* $NetBSD: main1.c,v 1.21 2013/04/19 17:43:05 christos Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: main1.c,v 1.20 2012/03/27 19:24:03 christos Exp $");
+__RCSID("$NetBSD: main1.c,v 1.21 2013/04/19 17:43:05 christos Exp $");
#endif
#include <sys/types.h>
@@ -222,9 +222,9 @@ main(int argc, char *argv[])
yyparse();
/* Following warnings cannot be suppressed by LINTED */
- nowarn = 0;
+ lwarn = LWARN_ALL;
#ifdef DEBUG
- printf("%s, %d: nowarn = 0\n", curr_pos.p_file, curr_pos.p_line);
+ printf("%s, %d: lwarn = %d\n", curr_pos.p_file, curr_pos.p_line, lwarn);
#endif
chkglsyms();
Index: src/usr.bin/xlint/lint1/scan.l
diff -u src/usr.bin/xlint/lint1/scan.l:1.50 src/usr.bin/xlint/lint1/scan.l:1.51
--- src/usr.bin/xlint/lint1/scan.l:1.50 Tue Mar 27 15:24:03 2012
+++ src/usr.bin/xlint/lint1/scan.l Fri Apr 19 13:43:05 2013
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: scan.l,v 1.50 2012/03/27 19:24:03 christos Exp $ */
+/* $NetBSD: scan.l,v 1.51 2013/04/19 17:43:05 christos Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -35,7 +35,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: scan.l,v 1.50 2012/03/27 19:24:03 christos Exp $");
+__RCSID("$NetBSD: scan.l,v 1.51 2013/04/19 17:43:05 christos Exp $");
#endif
#include <stdlib.h>
@@ -1111,7 +1111,7 @@ comment(void)
{ "FALLTHRU", 0, fallthru },
{ "FALLTHROUGH", 0, fallthru },
{ "LINTLIBRARY", 0, lintlib },
- { "LINTED", 0, linted },
+ { "LINTED", 1, linted },
{ "LONGLONG", 0, longlong },
{ "NOSTRICT", 0, linted },
{ "NOTREACHED", 0, notreach },
@@ -1222,7 +1222,7 @@ void
clrwflgs(void)
{
- nowarn = 0;
+ lwarn = LWARN_ALL;
quadflg = 0;
ccflg = 0;
}