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 lint: add missing redundant messages in ...



details:   https://anonhg.NetBSD.org/src/rev/8576d8ade77e
branches:  trunk
changeset: 1017593:8576d8ade77e
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Jan 01 11:41:01 2021 +0000

description:
lint: add missing redundant messages in source code

diffstat:

 usr.bin/xlint/lint1/cgram.y        |  18 +++++++++++--
 usr.bin/xlint/lint1/check-msgs.lua |   9 +++++-
 usr.bin/xlint/lint1/decl.c         |  33 +++++++++++++++----------
 usr.bin/xlint/lint1/func.c         |   7 +++--
 usr.bin/xlint/lint1/init.c         |   7 +++--
 usr.bin/xlint/lint1/tree.c         |  49 ++++++++++++++++++++++++-------------
 6 files changed, 81 insertions(+), 42 deletions(-)

diffs (truncated from 595 to 300 lines):

diff -r b61cabbe38e3 -r 8576d8ade77e usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y       Fri Jan 01 11:14:06 2021 +0000
+++ b/usr.bin/xlint/lint1/cgram.y       Fri Jan 01 11:41:01 2021 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.126 2021/01/01 11:09:40 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.127 2021/01/01 11:41:01 rillig 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.126 2021/01/01 11:09:40 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.127 2021/01/01 11:41:01 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -801,6 +801,7 @@
                symtyp = FVFT;
                /* struct or union member must be named */
                if (!Sflag)
+                       /* anonymous struct/union members is a C9X feature */
                        warning(49);
                /* add all the members of the anonymous struct/union */
                $$ = dcs->d_type->t_str->memb;
@@ -810,6 +811,7 @@
                symtyp = FVFT;
                /* struct or union member must be named */
                if (!Sflag)
+                       /* anonymous struct/union members is a C9X feature */
                        warning(49);
                $$ = dcs->d_type->t_str->memb;
                /* add all the members of the anonymous struct/union */
@@ -1363,10 +1365,12 @@
 init_field:
          T_LBRACK range T_RBRACK {
                if (!Sflag)
+                       /* array initializer with des.s is a C9X feature */
                        warning(321);
          }
        | point identifier {
                if (!Sflag)
+                       /* struct or union member name in initializer is ... */
                        warning(313);
                push_member($2);
          }
@@ -1380,6 +1384,7 @@
 init_by_name:
          init_field_list T_ASSIGN
        | identifier T_COLON {
+               /* GCC style struct or union member name in initializer */
                gnuism(315);
                push_member($1);
          }
@@ -1511,6 +1516,7 @@
          stmnt_list
        | stmnt_d_list declaration_list stmnt_list {
                if (!Sflag)
+                       /* declarations after statements is a C9X feature */
                        c99ism(327);
        }
        ;
@@ -1712,6 +1718,7 @@
 for_exprs:
          for_start declspecs deftyp notype_init_decls T_SEMI opt_expr
          T_SEMI opt_expr T_RPAREN {
+               /* variable declaration in for loop */
                c99ism(325);
                for1(NULL, $6, $8);
                CLRWFLGS(__FILE__, __LINE__);
@@ -1867,6 +1874,7 @@
                initsym = mktempsym(duptyp($4->tn_type));
                mblklev++;
                blklev++;
+               /* ({ }) is a GCC extension */
                gnuism(320);
        } comp_stmnt_rbrace T_RPAREN {
                $$ = getnnode(initsym, 0);
@@ -1877,6 +1885,7 @@
                initsym = mktempsym($3->tn_type);
                mblklev++;
                blklev++;
+               /* ({ }) is a GCC extension */
                gnuism(320);
        } comp_stmnt_rbrace T_RPAREN {
                $$ = getnnode(initsym, 0);
@@ -1971,7 +1980,8 @@
                idecl(tmp, 1, NULL);
          } init_lbrace init_expr_list init_rbrace {
                if (!Sflag)
-                       gnuism(319);
+                        /* compound literals are a C9X/GCC extension */
+                        gnuism(319);
                $$ = getnnode(initsym, 0);
          }
        ;
@@ -2017,6 +2027,7 @@
 point:
          T_STROP {
                if ($1 != POINT) {
+                       /* syntax error '%s' */
                        error(249, yytext);
                }
          }
@@ -2039,6 +2050,7 @@
 int
 yyerror(const char *msg)
 {
+       /* syntax error '%s' */
        error(249, yytext);
        if (++sytxerr >= 5)
                norecover();
diff -r b61cabbe38e3 -r 8576d8ade77e usr.bin/xlint/lint1/check-msgs.lua
--- a/usr.bin/xlint/lint1/check-msgs.lua        Fri Jan 01 11:14:06 2021 +0000
+++ b/usr.bin/xlint/lint1/check-msgs.lua        Fri Jan 01 11:41:01 2021 +0000
@@ -1,5 +1,5 @@
 #! /usr/bin/lua
--- $NetBSD: check-msgs.lua,v 1.3 2021/01/01 01:26:02 rillig Exp $
+-- $NetBSD: check-msgs.lua,v 1.4 2021/01/01 11:41:01 rillig Exp $
 
 --[[
 
@@ -45,6 +45,7 @@
   comment = string.gsub(comment, "conv%.", "conversion")
   comment = string.gsub(comment, "decl%.", "declaration")
   comment = string.gsub(comment, "defn%.", "definition")
+  comment = string.gsub(comment, "des%.s", "designators")
   comment = string.gsub(comment, "expr%.", "expression")
   comment = string.gsub(comment, "func%.", "function")
   comment = string.gsub(comment, "incomp%.", "incompatible")
@@ -80,11 +81,15 @@
     lineno = lineno + 1
 
     local func, id = line:match("^%s+(%w+)%((%d+)[),]")
+    id = tonumber(id)
     if func == "error" or func == "warning" or func == "c99ism" or
        func == "gnuism" or func == "message" then
       local comment = prev:match("^%s+/%* (.+) %*/$")
       if comment ~= nil then
-        check_message(fname, lineno, tonumber(id), comment, msgs, errors)
+        check_message(fname, lineno, id, comment, msgs, errors)
+      else
+        errors:add("%s:%d: missing comment for %d: /* %s */",
+          fname, lineno, id, msgs[id])
       end
     end
 
diff -r b61cabbe38e3 -r 8576d8ade77e usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c        Fri Jan 01 11:14:06 2021 +0000
+++ b/usr.bin/xlint/lint1/decl.c        Fri Jan 01 11:41:01 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.93 2021/01/01 09:28:22 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.94 2021/01/01 11:41:01 rillig 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.93 2021/01/01 09:28:22 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.94 2021/01/01 11:41:01 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -302,9 +302,10 @@
        if (t == COMPLEX) {
                if (dcs->d_cmod == FLOAT)
                        t = FCOMPLEX;
-               else if (dcs->d_cmod == DOUBLE) {
+               else if (dcs->d_cmod == DOUBLE)
                        t = DCOMPLEX;
-               } else
+               else
+                       /* Invalid type %s for _Complex */
                        error(308, tspec_name(dcs->d_cmod));
                dcs->d_cmod = NOTSPEC;
        }
@@ -528,6 +529,7 @@
                }
                break;
        default:
+               /* %s attribute ignored for %s */
                warning(326, "packed", tyname(buf, sizeof(buf), tp));
                break;
        }
@@ -1038,8 +1040,10 @@
                        } else if (incompl(tp)) {
                                /* array of incomplete type */
                                if (sflag) {
+                                       /* array of incomplete type */
                                        error(301);
                                } else {
+                                       /* array of incomplete type */
                                        warning(301);
                                }
 #endif
@@ -1110,10 +1114,7 @@
                        if (bitfieldtype_ok == 0) {
                                if (sflag) {
                                        char buf[64];
-                                       /*
-                                        * bit-field type '%s' invalid in
-                                        * ANSI C
-                                        */
+                                       /* bit-field type '%s' invalid ... */
                                        warning(273,
                                            tyname(buf, sizeof(buf), tp));
                                } else if (pflag) {
@@ -1714,6 +1715,7 @@
                            tag->s_name);
                        /* declaration introduces new type in ANSI C: %s %s */
                        if (!sflag) {
+                               /* decl. introduces new type in ANSI C: %s %s */
                                warning(44, storage_class_name(scl),
                                    tag->s_name);
                        }
@@ -2066,6 +2068,7 @@
         */
        /* redeclaration of %s; ANSI C requires "static" */
        if (sflag) {
+               /* redeclaration of %s; ANSI C requires static */
                warning(30, dsym->s_name);
                print_previous_declaration(-1, rsym);
        }
@@ -2613,18 +2616,18 @@
 
                        switch (dsym->s_scl) {
                        case AUTO:
-                               /* automatic hides external declaration: %s */
                                if (hflag)
+                                       /* automatic hides external decl.: %s */
                                        warning(86, dsym->s_name);
                                break;
                        case STATIC:
-                               /* static hides external declaration: %s */
                                if (hflag)
+                                       /* static hides external decl.: %s */
                                        warning(87, dsym->s_name);
                                break;
                        case TYPEDEF:
-                               /* typedef hides external declaration: %s */
                                if (hflag)
+                                       /* typedef hides external decl.: %s */
                                        warning(88, dsym->s_name);
                                break;
                        case EXTERN:
@@ -2762,8 +2765,10 @@
        } else if (sym->s_scl == EXTERN && sym->s_def == DECL) {
                /* cannot initialize "extern" declaration: %s */
                if (dcs->d_ctx == EXTERN) {
+                       /* cannot initialize extern declaration: %s */
                        warning(26, sym->s_name);
                } else {
+                       /* cannot initialize extern declaration: %s */
                        error(26, sym->s_name);
                        erred = 1;
                }
@@ -2848,10 +2853,11 @@
 
        if (length(dsym->s_type, dsym->s_name) == 0 &&
            dsym->s_type->t_tspec == ARRAY && dsym->s_type->t_dim == 0) {
-               /* empty array declaration: %s */
                if (tflag) {
+                       /* empty array declaration: %s */
                        warning(190, dsym->s_name);
                } else {
+                       /* empty array declaration: %s */
                        error(190, dsym->s_name);
                }
        }
@@ -3173,10 +3179,11 @@
                curr_pos = sym->s_def_pos;
                if (length(sym->s_type, sym->s_name) == 0 &&
                    sym->s_type->t_tspec == ARRAY && sym->s_type->t_dim == 0) {
-                       /* empty array declaration: %s */
                        if (tflag || (sym->s_scl == EXTERN && !sflag)) {
+                               /* empty array declaration: %s */
                                warning(190, sym->s_name);
                        } else {
+                               /* empty array declaration: %s */
                                error(190, sym->s_name);
                        }
                }
diff -r b61cabbe38e3 -r 8576d8ade77e usr.bin/xlint/lint1/func.c
--- a/usr.bin/xlint/lint1/func.c        Fri Jan 01 11:14:06 2021 +0000
+++ b/usr.bin/xlint/lint1/func.c        Fri Jan 01 11:41:01 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: func.c,v 1.45 2021/01/01 11:14:06 rillig Exp $ */
+/*     $NetBSD: func.c,v 1.46 2021/01/01 11:41:01 rillig 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.45 2021/01/01 11:14:06 rillig Exp $");



Home | Main Index | Thread Index | Old Index