summaryrefslogtreecommitdiff
path: root/usr.bin/xlint
diff options
context:
space:
mode:
authorChad Loder <cloder@cvs.openbsd.org>2006-04-20 16:29:49 +0000
committerChad Loder <cloder@cvs.openbsd.org>2006-04-20 16:29:49 +0000
commit1c0b32d41cb46768feb15eb04e6809c3bd74378a (patch)
treeff6cb9a4bd5495cedb554942285df728fce98299 /usr.bin/xlint
parentdc8b2a5c7c7f37900657cd2588118b262752607b (diff)
Add a LINTUSED special comment which marks the following declared symbol(s)
as used so that lint2 doesn't complain. Prodded by deraadt
Diffstat (limited to 'usr.bin/xlint')
-rw-r--r--usr.bin/xlint/lint1/cgram.y7
-rw-r--r--usr.bin/xlint/lint1/externs1.h4
-rw-r--r--usr.bin/xlint/lint1/func.c21
-rw-r--r--usr.bin/xlint/lint1/scan.l6
4 files changed, 31 insertions, 7 deletions
diff --git a/usr.bin/xlint/lint1/cgram.y b/usr.bin/xlint/lint1/cgram.y
index d519b4786a3..5587b537cc7 100644
--- a/usr.bin/xlint/lint1/cgram.y
+++ b/usr.bin/xlint/lint1/cgram.y
@@ -1,5 +1,5 @@
%{
-/* $OpenBSD: cgram.y,v 1.17 2005/12/10 18:42:45 cloder Exp $ */
+/* $OpenBSD: cgram.y,v 1.18 2006/04/20 16:29:48 cloder Exp $ */
/* $NetBSD: cgram.y,v 1.8 1995/10/02 17:31:35 jpo Exp $ */
/*
@@ -34,7 +34,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: cgram.y,v 1.17 2005/12/10 18:42:45 cloder Exp $";
+static char rcsid[] = "$OpenBSD: cgram.y,v 1.18 2006/04/20 16:29:48 cloder Exp $";
#endif
#include <stdlib.h>
@@ -1668,6 +1668,9 @@ idecl(sym_t *decl, int initflg)
initerr = 0;
initsym = decl;
+ if (usedflg)
+ setuflg(decl, 0, 0);
+
switch (dcs->d_ctx) {
case EXTERN:
decl1ext(decl, initflg);
diff --git a/usr.bin/xlint/lint1/externs1.h b/usr.bin/xlint/lint1/externs1.h
index 0962079563f..4a50ac3ffc9 100644
--- a/usr.bin/xlint/lint1/externs1.h
+++ b/usr.bin/xlint/lint1/externs1.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: externs1.h,v 1.11 2006/04/18 02:59:40 cloder Exp $ */
+/* $OpenBSD: externs1.h,v 1.12 2006/04/20 16:29:48 cloder Exp $ */
/* $NetBSD: externs1.h,v 1.7 1995/10/02 17:31:39 jpo Exp $ */
/*
@@ -226,6 +226,7 @@ extern int ccflg;
extern int llibflg;
extern int nowarn;
extern int noretflg;
+extern int usedflg;
extern int plibflg;
extern int quadflg;
@@ -253,6 +254,7 @@ extern void doreturn(tnode_t *);
extern void glclup(int);
extern void argsused(int);
extern void noreturn(int);
+extern void lintused(int);
extern void constcond(int);
extern void fallthru(int);
extern void notreach(int);
diff --git a/usr.bin/xlint/lint1/func.c b/usr.bin/xlint/lint1/func.c
index 5f68f9d6dc7..d909c51f6d1 100644
--- a/usr.bin/xlint/lint1/func.c
+++ b/usr.bin/xlint/lint1/func.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: func.c,v 1.13 2006/04/20 03:40:29 cloder Exp $ */
+/* $OpenBSD: func.c,v 1.14 2006/04/20 16:29:48 cloder Exp $ */
/* $NetBSD: func.c,v 1.7 1995/10/02 17:31:40 jpo Exp $ */
/*
@@ -33,7 +33,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: func.c,v 1.13 2006/04/20 03:40:29 cloder Exp $";
+static char rcsid[] = "$OpenBSD: func.c,v 1.14 2006/04/20 16:29:48 cloder Exp $";
#endif
#include <stdlib.h>
@@ -90,6 +90,12 @@ pos_t aupos;
int noretflg = 0;
/*
+ * If the following symbol should be marked as having been used, even if
+ * lint thinks otherwise, usedflg is set to 1. Otherwise it is set to 0.
+ */
+int usedflg = 0;
+
+/*
* Number of arguments of the following function definition whose types
* shall be checked by lint2. -1 stands for all arguments.
*
@@ -1129,6 +1135,17 @@ noreturn(int n)
}
/*
+ * LINTUSED comment
+ *
+ * Mark a symbol as used, so lint2 does not complain.
+ */
+void
+lintused(int n)
+{
+ usedflg = 1;
+}
+
+/*
* VARARGS comment
*
* Makes that lint2 checks only the first n arguments for compatibility
diff --git a/usr.bin/xlint/lint1/scan.l b/usr.bin/xlint/lint1/scan.l
index 50802fa2afd..96a9ce5e7dd 100644
--- a/usr.bin/xlint/lint1/scan.l
+++ b/usr.bin/xlint/lint1/scan.l
@@ -1,5 +1,5 @@
%{
-/* $OpenBSD: scan.l,v 1.28 2006/03/13 21:12:32 moritz Exp $ */
+/* $OpenBSD: scan.l,v 1.29 2006/04/20 16:29:48 cloder Exp $ */
/* $NetBSD: scan.l,v 1.8 1995/10/23 13:38:51 jpo Exp $ */
/*
@@ -34,7 +34,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: scan.l,v 1.28 2006/03/13 21:12:32 moritz Exp $";
+static char rcsid[] = "$OpenBSD: scan.l,v 1.29 2006/04/20 16:29:48 cloder Exp $";
#endif
#include <stdlib.h>
@@ -1061,6 +1061,7 @@ comment(void)
{ "FALLTHROUGH", 0, fallthru },
{ "LINTLIBRARY", 0, lintlib },
{ "LINTED", 0, linted },
+ { "LINTUSED", 0, lintused },
{ "LONGLONG", 0, longlong },
{ "NOSTRICT", 0, linted },
{ "NOTREACHED", 0, notreach },
@@ -1166,6 +1167,7 @@ clrwflgs(void)
nowarn = 0;
quadflg = 1;
ccflg = 0;
+ usedflg = 0;
}
/*