Allow linted comments to take an argument that defines which error to suppress.
This commit is contained in:
parent
7d19b890df
commit
32c6bb3802
|
@ -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 *file, size_t line)
|
|||
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();
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue