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: split cluparg into separate functions



details:   https://anonhg.NetBSD.org/src/rev/6252ef565f22
branches:  trunk
changeset: 948747:6252ef565f22
user:      rillig <rillig%NetBSD.org@localhost>
date:      Wed Dec 30 13:17:42 2020 +0000

description:
lint: split cluparg into separate functions

That function did more than its short name could express, and the things
it did were not related in any way.

diffstat:

 usr.bin/xlint/lint1/cgram.y    |   7 ++++---
 usr.bin/xlint/lint1/decl.c     |  39 +++++++++++++++++++++------------------
 usr.bin/xlint/lint1/externs1.h |   6 ++++--
 usr.bin/xlint/lint1/func.c     |   6 +++---
 4 files changed, 32 insertions(+), 26 deletions(-)

diffs (153 lines):

diff -r 78e9699f0216 -r 6252ef565f22 usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y       Wed Dec 30 13:15:07 2020 +0000
+++ b/usr.bin/xlint/lint1/cgram.y       Wed Dec 30 13:17:42 2020 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.121 2020/12/30 10:56:51 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.122 2020/12/30 13:17:42 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.121 2020/12/30 10:56:51 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.122 2020/12/30 13:17:42 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -429,7 +429,8 @@
          } opt_arg_declaration_list {
                popdecl();
                blklev--;
-               cluparg();
+               check_func_lint_directives();
+               check_func_old_style_arguments();
                pushctrl(0);
          } comp_stmnt {
                funcend();
diff -r 78e9699f0216 -r 6252ef565f22 usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c        Wed Dec 30 13:15:07 2020 +0000
+++ b/usr.bin/xlint/lint1/decl.c        Wed Dec 30 13:17:42 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.86 2020/12/30 11:56:10 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.87 2020/12/30 13:17:42 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.86 2020/12/30 11:56:10 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.87 2020/12/30 13:17:42 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -2392,22 +2392,12 @@
        return sym;
 }
 
-/*
- * Does some checks for lint directives which apply to functions.
- * Processes arguments in old style function definitions which default
- * to int.
- * Checks compatiblility of old style function definition with previous
- * prototype.
- */
 void
-cluparg(void)
+check_func_lint_directives(void)
 {
-       sym_t   *args, *arg, *pargs, *parg;
-       int     narg, nparg, n, msg;
-       tspec_t t;
-
-       args = funcsym->s_args;
-       pargs = funcsym->s_type->t_args;
+       sym_t *arg;
+       int narg, n;
+       tspec_t t;
 
        /* check for illegal combinations of lint directives */
        if (prflstrg != -1 && scflstrg != -1) {
@@ -2465,6 +2455,21 @@
                        prflstrg = scflstrg = -1;
                }
        }
+}
+
+/*
+ * Warn about arguments in old style function definitions that default to int.
+ * Check that an old style function definition is compatible to a previous
+ * prototype.
+ */
+void
+check_func_old_style_arguments(void)
+{
+       sym_t *args, *arg, *pargs, *parg;
+       int narg, nparg, msg;
+
+       args = funcsym->s_args;
+       pargs = funcsym->s_type->t_args;
 
        /*
         * print a warning for each argument of an old style function
@@ -2514,9 +2519,7 @@
                /* from now on the prototype is valid */
                funcsym->s_osdef = 0;
                funcsym->s_args = NULL;
-
        }
-
 }
 
 /*
diff -r 78e9699f0216 -r 6252ef565f22 usr.bin/xlint/lint1/externs1.h
--- a/usr.bin/xlint/lint1/externs1.h    Wed Dec 30 13:15:07 2020 +0000
+++ b/usr.bin/xlint/lint1/externs1.h    Wed Dec 30 13:17:42 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: externs1.h,v 1.41 2020/12/30 01:33:30 rillig Exp $     */
+/*     $NetBSD: externs1.h,v 1.42 2020/12/30 13:17:42 rillig Exp $     */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -178,7 +178,9 @@
 extern int     eqtype(type_t *, type_t *, int, int, int *);
 extern void    complete_type(sym_t *, sym_t *);
 extern sym_t   *decl1arg(sym_t *, int);
-extern void    cluparg(void);
+extern void    check_func_lint_directives(void);
+extern void    check_func_old_style_arguments(void);
+
 extern void    decl1loc(sym_t *, int);
 extern sym_t   *abstract_name(void);
 extern void    global_clean_up(void);
diff -r 78e9699f0216 -r 6252ef565f22 usr.bin/xlint/lint1/func.c
--- a/usr.bin/xlint/lint1/func.c        Wed Dec 30 13:15:07 2020 +0000
+++ b/usr.bin/xlint/lint1/func.c        Wed Dec 30 13:17:42 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: func.c,v 1.37 2020/12/30 11:56:10 rillig Exp $ */
+/*     $NetBSD: func.c,v 1.38 2020/12/30 13:17:42 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.37 2020/12/30 11:56:10 rillig Exp $");
+__RCSID("$NetBSD: func.c,v 1.38 2020/12/30 13:17:42 rillig Exp $");
 #endif
 
 #include <stdlib.h>
@@ -294,7 +294,7 @@
                        /*
                         * Print nothing if the newly defined function
                         * is defined in old style. A better warning will
-                        * be printed in cluparg().
+                        * be printed in check_func_lint_directives().
                         */
                        if (dowarn && !fsym->s_osdef) {
                                /* redeclaration of %s */



Home | Main Index | Thread Index | Old Index