Module Name:    src
Committed By:   rillig
Date:           Wed Dec 30 13:17:42 UTC 2020

Modified Files:
        src/usr.bin/xlint/lint1: cgram.y decl.c externs1.h func.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.121 -r1.122 src/usr.bin/xlint/lint1/cgram.y
cvs rdiff -u -r1.86 -r1.87 src/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.41 -r1.42 src/usr.bin/xlint/lint1/externs1.h
cvs rdiff -u -r1.37 -r1.38 src/usr.bin/xlint/lint1/func.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/xlint/lint1/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.121 src/usr.bin/xlint/lint1/cgram.y:1.122
--- src/usr.bin/xlint/lint1/cgram.y:1.121	Wed Dec 30 10:56:51 2020
+++ src/usr.bin/xlint/lint1/cgram.y	Wed Dec 30 13:17:42 2020
@@ -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 @@ func_def:
 	  } opt_arg_declaration_list {
 		popdecl();
 		blklev--;
-		cluparg();
+		check_func_lint_directives();
+		check_func_old_style_arguments();
 		pushctrl(0);
 	  } comp_stmnt {
 		funcend();

Index: src/usr.bin/xlint/lint1/decl.c
diff -u src/usr.bin/xlint/lint1/decl.c:1.86 src/usr.bin/xlint/lint1/decl.c:1.87
--- src/usr.bin/xlint/lint1/decl.c:1.86	Wed Dec 30 11:56:10 2020
+++ src/usr.bin/xlint/lint1/decl.c	Wed Dec 30 13:17:42 2020
@@ -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 @@ decl1arg(sym_t *sym, int initflg)
 	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 @@ cluparg(void)
 			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 @@ cluparg(void)
 		/* from now on the prototype is valid */
 		funcsym->s_osdef = 0;
 		funcsym->s_args = NULL;
-
 	}
-
 }
 
 /*

Index: src/usr.bin/xlint/lint1/externs1.h
diff -u src/usr.bin/xlint/lint1/externs1.h:1.41 src/usr.bin/xlint/lint1/externs1.h:1.42
--- src/usr.bin/xlint/lint1/externs1.h:1.41	Wed Dec 30 01:33:30 2020
+++ src/usr.bin/xlint/lint1/externs1.h	Wed Dec 30 13:17:42 2020
@@ -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	eqptrtype(type_t *, type_t *,
 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);

Index: src/usr.bin/xlint/lint1/func.c
diff -u src/usr.bin/xlint/lint1/func.c:1.37 src/usr.bin/xlint/lint1/func.c:1.38
--- src/usr.bin/xlint/lint1/func.c:1.37	Wed Dec 30 11:56:10 2020
+++ src/usr.bin/xlint/lint1/func.c	Wed Dec 30 13:17:42 2020
@@ -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 @@ funcdef(sym_t *fsym)
 			/*
 			 * 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 */

Reply via email to