Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/xlint/lint1 Allow linted comments to take an argumen...



details:   https://anonhg.NetBSD.org/src/rev/31eae7b49fd5
branches:  trunk
changeset: 786198:31eae7b49fd5
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Apr 19 17:43:05 2013 +0000

description:
Allow linted comments to take an argument that defines which error to suppress.

diffstat:

 usr.bin/xlint/lint1/cgram.y    |  30 +++++++++++++++---------------
 usr.bin/xlint/lint1/decl.c     |  19 ++++++++++---------
 usr.bin/xlint/lint1/err.c      |  13 ++++++++-----
 usr.bin/xlint/lint1/externs1.h |   4 ++--
 usr.bin/xlint/lint1/func.c     |  14 +++++++++-----
 usr.bin/xlint/lint1/lint1.h    |   6 +++++-
 usr.bin/xlint/lint1/main1.c    |   8 ++++----
 usr.bin/xlint/lint1/scan.l     |   8 ++++----
 8 files changed, 57 insertions(+), 45 deletions(-)

diffs (truncated from 327 to 300 lines):

diff -r ee79aa274487 -r 31eae7b49fd5 usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y       Fri Apr 19 16:53:18 2013 +0000
+++ b/usr.bin/xlint/lint1/cgram.y       Fri Apr 19 17:43:05 2013 +0000
@@ -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 @@
  * 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 @@
        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 @@
                funcdef($1);
                blklev++;
                pushdecl(ARG);
-               if (nowarn)
+               if (lwarn == LWARN_NONE)
                        $1->s_used = 1;
          } opt_arg_declaration_list {
                popdecl();
diff -r ee79aa274487 -r 31eae7b49fd5 usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c        Fri Apr 19 16:53:18 2013 +0000
+++ b/usr.bin/xlint/lint1/decl.c        Fri Apr 19 17:43:05 2013 +0000
@@ -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 @@
 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
 }
 
diff -r ee79aa274487 -r 31eae7b49fd5 usr.bin/xlint/lint1/err.c
--- a/usr.bin/xlint/lint1/err.c Fri Apr 19 16:53:18 2013 +0000
+++ b/usr.bin/xlint/lint1/err.c Fri Apr 19 17:43:05 2013 +0000
@@ -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 @@
 
 
 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 @@
 }
 
 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;
 
diff -r ee79aa274487 -r 31eae7b49fd5 usr.bin/xlint/lint1/externs1.h
--- a/usr.bin/xlint/lint1/externs1.h    Fri Apr 19 16:53:18 2013 +0000
+++ b/usr.bin/xlint/lint1/externs1.h    Fri Apr 19 17:43:05 2013 +0000
@@ -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 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;
diff -r ee79aa274487 -r 31eae7b49fd5 usr.bin/xlint/lint1/func.c
--- a/usr.bin/xlint/lint1/func.c        Fri Apr 19 16:53:18 2013 +0000
+++ b/usr.bin/xlint/lint1/func.c        Fri Apr 19 17:43:05 2013 +0000
@@ -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 @@
 
 /*
  * 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 @@
 {
 
 #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;
 }
 
 /*
diff -r ee79aa274487 -r 31eae7b49fd5 usr.bin/xlint/lint1/lint1.h
--- a/usr.bin/xlint/lint1/lint1.h       Fri Apr 19 16:53:18 2013 +0000
+++ b/usr.bin/xlint/lint1/lint1.h       Fri Apr 19 17:43:05 2013 +0000
@@ -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.
  */
diff -r ee79aa274487 -r 31eae7b49fd5 usr.bin/xlint/lint1/main1.c
--- a/usr.bin/xlint/lint1/main1.c       Fri Apr 19 16:53:18 2013 +0000
+++ b/usr.bin/xlint/lint1/main1.c       Fri Apr 19 17:43:05 2013 +0000
@@ -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 @@
        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();
diff -r ee79aa274487 -r 31eae7b49fd5 usr.bin/xlint/lint1/scan.l
--- a/usr.bin/xlint/lint1/scan.l        Fri Apr 19 16:53:18 2013 +0000
+++ b/usr.bin/xlint/lint1/scan.l        Fri Apr 19 17:43:05 2013 +0000
@@ -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.



Home | Main Index | Thread Index | Old Index