Module Name:    src
Committed By:   rillig
Date:           Mon Jan 11 19:29:49 UTC 2021

Modified Files:
        src/usr.bin/xlint/lint1: decl.c emit1.c externs1.h tree.c

Log Message:
lint: sprinkle a few const modifiers throughout the code


To generate a diff of this commit:
cvs rdiff -u -r1.120 -r1.121 src/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.35 -r1.36 src/usr.bin/xlint/lint1/emit1.c
cvs rdiff -u -r1.53 -r1.54 src/usr.bin/xlint/lint1/externs1.h
cvs rdiff -u -r1.148 -r1.149 src/usr.bin/xlint/lint1/tree.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/decl.c
diff -u src/usr.bin/xlint/lint1/decl.c:1.120 src/usr.bin/xlint/lint1/decl.c:1.121
--- src/usr.bin/xlint/lint1/decl.c:1.120	Sun Jan 10 18:22:52 2021
+++ src/usr.bin/xlint/lint1/decl.c	Mon Jan 11 19:29:49 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.120 2021/01/10 18:22:52 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.121 2021/01/11 19:29:49 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.120 2021/01/10 18:22:52 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.121 2021/01/11 19:29:49 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -67,8 +67,8 @@ static	void	settdsym(type_t *, sym_t *);
 static	tspec_t	merge_type_specifiers(tspec_t, tspec_t);
 static	void	align(int, int);
 static	sym_t	*newtag(sym_t *, scl_t, int, int);
-static	int	eqargs(type_t *, type_t *, int *);
-static	int	mnoarg(type_t *, int *);
+static	int	eqargs(const type_t *, const type_t *, int *);
+static	int	mnoarg(const type_t *, int *);
 static	int	check_old_style_definition(sym_t *, sym_t *);
 static	int	check_prototype_declaration(sym_t *, sym_t *);
 static	sym_t	*new_style_function(sym_t *, sym_t *);
@@ -172,7 +172,7 @@ tduptyp(const type_t *tp)
  * struct, union or enum type.
  */
 int
-incompl(type_t *tp)
+incompl(const type_t *tp)
 {
 	tspec_t	t;
 
@@ -882,7 +882,7 @@ merge_type_specifiers(tspec_t t, tspec_t
  * if name is not NULL.
  */
 int
-length(type_t *tp, const char *name)
+length(const type_t *tp, const char *name)
 {
 	int	elem, elsz;
 
@@ -926,7 +926,7 @@ length(type_t *tp, const char *name)
  * Get the alignment of the given Type in bits.
  */
 int
-getbound(type_t *tp)
+getbound(const type_t *tp)
 {
 	size_t	a;
 	tspec_t	t;
@@ -2108,7 +2108,8 @@ eqptrtype(const type_t *tp1, const type_
  *		compatible with a prototype
  */
 int
-eqtype(type_t *tp1, type_t *tp2, int ignqual, int promot, int *dowarn)
+eqtype(const type_t *tp1, const type_t *tp2,
+       int ignqual, int promot, int *dowarn)
 {
 	tspec_t	t;
 
@@ -2171,7 +2172,7 @@ eqtype(type_t *tp1, type_t *tp2, int ign
  * Compares the parameter types of two prototypes.
  */
 static int
-eqargs(type_t *tp1, type_t *tp2, int *dowarn)
+eqargs(const type_t *tp1, const type_t *tp2, int *dowarn)
 {
 	sym_t	*a1, *a2;
 
@@ -2205,7 +2206,7 @@ eqargs(type_t *tp1, type_t *tp2, int *do
  *	   is applied on it
  */
 static int
-mnoarg(type_t *tp, int *dowarn)
+mnoarg(const type_t *tp, int *dowarn)
 {
 	sym_t	*arg;
 	tspec_t	t;
@@ -3213,7 +3214,7 @@ check_global_variable_size(const sym_t *
  * Prints information about location of previous definition/declaration.
  */
 void
-print_previous_declaration(int msg, sym_t *psym)
+print_previous_declaration(int msg, const sym_t *psym)
 {
 	pos_t	cpos;
 

Index: src/usr.bin/xlint/lint1/emit1.c
diff -u src/usr.bin/xlint/lint1/emit1.c:1.35 src/usr.bin/xlint/lint1/emit1.c:1.36
--- src/usr.bin/xlint/lint1/emit1.c:1.35	Sun Jan 10 00:05:46 2021
+++ src/usr.bin/xlint/lint1/emit1.c	Mon Jan 11 19:29:49 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: emit1.c,v 1.35 2021/01/10 00:05:46 rillig Exp $ */
+/* $NetBSD: emit1.c,v 1.36 2021/01/11 19:29:49 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: emit1.c,v 1.35 2021/01/10 00:05:46 rillig Exp $");
+__RCSID("$NetBSD: emit1.c,v 1.36 2021/01/11 19:29:49 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -92,7 +92,7 @@ static	void	outfstrg(strg_t *);
  * and 'v' (for volatile)
  */
 void
-outtype(type_t *tp)
+outtype(const type_t *tp)
 {
 	int	t, s, na;
 	sym_t	*arg;
@@ -166,7 +166,7 @@ outtype(type_t *tp)
  * it uses its own output buffer for conversion
  */
 const char *
-ttos(type_t *tp)
+ttos(const type_t *tp)
 {
 	static	ob_t	tob;
 	ob_t	tmp;
@@ -226,7 +226,7 @@ outtt(sym_t *tag, sym_t *tdef)
  * not here
  */
 void
-outsym(sym_t *sym, scl_t sc, def_t def)
+outsym(const sym_t *sym, scl_t sc, def_t def)
 {
 
 	/*
@@ -301,10 +301,11 @@ outsym(sym_t *sym, scl_t sc, def_t def)
  * they are called with proper argument types
  */
 void
-outfdef(sym_t *fsym, pos_t *posp, int rval, int osdef, sym_t *args)
+outfdef(const sym_t *fsym, const pos_t *posp, int rval, int osdef,
+	const sym_t *args)
 {
-	int	narg;
-	sym_t	*arg;
+	int narg;
+	const sym_t *arg;
 
 	/* reset the buffer */
 	outclr();
@@ -406,7 +407,7 @@ outfdef(sym_t *fsym, pos_t *posp, int rv
  * (casted to void)
  */
 void
-outcall(tnode_t *tn, int rvused, int rvdisc)
+outcall(const tnode_t *tn, int rvused, int rvdisc)
 {
 	tnode_t	*args, *arg;
 	int	narg, n, i;
@@ -591,7 +592,7 @@ outfstrg(strg_t *strg)
  * writes a record if sym was used
  */
 void
-outusg(sym_t *sym)
+outusg(const sym_t *sym)
 {
 	/* reset buffer */
 	outclr();

Index: src/usr.bin/xlint/lint1/externs1.h
diff -u src/usr.bin/xlint/lint1/externs1.h:1.53 src/usr.bin/xlint/lint1/externs1.h:1.54
--- src/usr.bin/xlint/lint1/externs1.h:1.53	Sun Jan 10 14:09:57 2021
+++ src/usr.bin/xlint/lint1/externs1.h	Mon Jan 11 19:29:49 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: externs1.h,v 1.53 2021/01/10 14:09:57 rillig Exp $	*/
+/*	$NetBSD: externs1.h,v 1.54 2021/01/11 19:29:49 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -141,7 +141,7 @@ extern	void	initdecl(void);
 extern	type_t	*gettyp(tspec_t);
 extern	type_t	*duptyp(const type_t *);
 extern	type_t	*tduptyp(const type_t *);
-extern	int	incompl(type_t *);
+extern	int	incompl(const type_t *);
 extern	void	setcomplete(type_t *, int);
 extern	void	add_storage_class(scl_t);
 extern	void	add_type(type_t *);
@@ -153,8 +153,8 @@ extern	void	popdecl(void);
 extern	void	setasm(void);
 extern	void	clrtyp(void);
 extern	void	deftyp(void);
-extern	int	length(type_t *, const char *);
-extern	int	getbound(type_t *);
+extern	int	length(const type_t *, const char *);
+extern	int	getbound(const type_t *);
 extern	sym_t	*lnklst(sym_t *, sym_t *);
 extern	void	check_type(sym_t *);
 extern	sym_t	*declarator_1_struct_union(sym_t *);
@@ -175,7 +175,7 @@ extern	void	decl1ext(sym_t *, int);
 extern	void	copy_usage_info(sym_t *, sym_t *);
 extern	int	check_redeclaration(sym_t *, int *);
 extern	bool	eqptrtype(const type_t *, const type_t *, int);
-extern	int	eqtype(type_t *, type_t *, int, int, int *);
+extern	int	eqtype(const type_t *, const type_t *, int, int, int *);
 extern	void	complete_type(sym_t *, sym_t *);
 extern	sym_t	*declare_argument(sym_t *, int);
 extern	void	check_func_lint_directives(void);
@@ -191,7 +191,7 @@ extern	void	mark_as_used(sym_t *, int, i
 extern	void	check_usage(dinfo_t *);
 extern	void	check_usage_sym(int, sym_t *);
 extern	void	check_global_symbols(void);
-extern	void	print_previous_declaration(int, sym_t *);
+extern	void	print_previous_declaration(int, const sym_t *);
 
 /*
  * tree.c
@@ -204,7 +204,7 @@ extern	tnode_t	*new_string_node(strg_t *
 extern	sym_t	*struct_or_union_member(tnode_t *, op_t, sym_t *);
 extern	tnode_t	*build(op_t, tnode_t *, tnode_t *);
 extern	tnode_t	*cconv(tnode_t *);
-extern	bool	typeok(op_t, int, tnode_t *, tnode_t *);
+extern	bool	typeok(op_t, int, const tnode_t *, const tnode_t *);
 extern	tnode_t	*promote(op_t, int, tnode_t *);
 extern	tnode_t	*convert(op_t, int, type_t *, tnode_t *);
 extern	void	convert_constant(op_t, int, type_t *, val_t *, val_t *);
@@ -216,7 +216,7 @@ extern	tnode_t	*new_function_argument_no
 extern	tnode_t	*new_function_call_node(tnode_t *, tnode_t *);
 extern	val_t	*constant(tnode_t *, int);
 extern	void	expr(tnode_t *, int, int, int);
-extern	void	check_expr_misc(tnode_t *, int, int, int, int, int, int);
+extern	void	check_expr_misc(const tnode_t *, int, int, int, int, int, int);
 extern	int	conaddr(tnode_t *, sym_t **, ptrdiff_t *);
 extern	strg_t	*cat_strings(strg_t *, strg_t *);
 extern  int64_t tsize(type_t *);
@@ -296,12 +296,12 @@ extern	void	push_member(sbuf_t *);
 /*
  * emit.c
  */
-extern	void	outtype(type_t *);
-extern	const	char *ttos(type_t *);
-extern	void	outsym(sym_t *, scl_t, def_t);
-extern	void	outfdef(sym_t *, pos_t *, int, int, sym_t *);
-extern	void	outcall(tnode_t *, int, int);
-extern	void	outusg(sym_t *);
+extern	void	outtype(const type_t *);
+extern	const	char *ttos(const type_t *);
+extern	void	outsym(const sym_t *, scl_t, def_t);
+extern	void	outfdef(const sym_t *, const pos_t *, int, int, const sym_t *);
+extern	void	outcall(const tnode_t *, int, int);
+extern	void	outusg(const sym_t *);
 
 /*
  * print.c

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.148 src/usr.bin/xlint/lint1/tree.c:1.149
--- src/usr.bin/xlint/lint1/tree.c:1.148	Sun Jan 10 12:46:38 2021
+++ src/usr.bin/xlint/lint1/tree.c	Mon Jan 11 19:29:49 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.148 2021/01/10 12:46:38 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.149 2021/01/11 19:29:49 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.148 2021/01/10 12:46:38 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.149 2021/01/11 19:29:49 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -51,17 +51,23 @@ __RCSID("$NetBSD: tree.c,v 1.148 2021/01
 #include "cgram.h"
 
 static	tnode_t	*new_integer_constant_node(tspec_t, int64_t);
-static	void	check_pointer_comparison(op_t, tnode_t *, tnode_t *);
-static	int	check_assign_types_compatible(op_t, int, tnode_t *, tnode_t *);
-static	void	check_bad_enum_operation(op_t, tnode_t *, tnode_t *);
-static	void	check_enum_type_mismatch(op_t, int, tnode_t *, tnode_t *);
-static	void	check_enum_int_mismatch(op_t, int, tnode_t *, tnode_t *);
+static	void	check_pointer_comparison(op_t,
+					 const tnode_t *, const tnode_t *);
+static	int	check_assign_types_compatible(op_t, int,
+					      const tnode_t *, const tnode_t *);
+static	void	check_bad_enum_operation(op_t,
+					 const tnode_t *, const tnode_t *);
+static	void	check_enum_type_mismatch(op_t, int,
+				         const tnode_t *, const tnode_t *);
+static	void	check_enum_int_mismatch(op_t, int,
+					const tnode_t *, const tnode_t *);
 static	tnode_t	*new_tnode(op_t, type_t *, tnode_t *, tnode_t *);
 static	void	balance(op_t, tnode_t **, tnode_t **);
 static	void	warn_incompatible_types(op_t, tspec_t, tspec_t);
-static	void	warn_incompatible_pointers(mod_t *, type_t *, type_t *);
+static	void	warn_incompatible_pointers(const mod_t *,
+					   const type_t *, const type_t *);
 static	void	merge_qualifiers(type_t **, type_t *, type_t *);
-static	int	has_constant_member(type_t *);
+static	bool	has_constant_member(const type_t *);
 static	void	check_prototype_conversion(int, tspec_t, tspec_t, type_t *,
 					   tnode_t *);
 static	void	check_integer_conversion(op_t, int, tspec_t, tspec_t, type_t *,
@@ -83,8 +89,8 @@ static	tnode_t	*fold_test(tnode_t *);
 static	tnode_t	*fold_float(tnode_t *);
 static	tnode_t	*check_function_arguments(type_t *, tnode_t *);
 static	tnode_t	*check_prototype_argument(int, type_t *, tnode_t *);
-static	void	check_null_effect(tnode_t *);
-static	void	display_expression(tnode_t *, int);
+static	void	check_null_effect(const tnode_t *);
+static	void	display_expression(const tnode_t *, int);
 static	void	check_array_index(tnode_t *, int);
 static	void	check_integer_comparison(op_t, tnode_t *, tnode_t *);
 static	void	check_precedence_confusion(tnode_t *);
@@ -687,13 +693,13 @@ cconv(tnode_t *tn)
 }
 
 static bool
-typeok_incdec(mod_t *const mp, tnode_t *const ln, type_t *const ltp)
+typeok_incdec(const mod_t *mp, const tnode_t *tn, const type_t *tp)
 {
 	/* operand has scalar type (checked in typeok) */
-	if (!ln->tn_lvalue) {
-		if (ln->tn_op == CVT && ln->tn_cast &&
-		    ln->tn_left->tn_op == LOAD) {
-			if (ln->tn_type->t_tspec == PTR)
+	if (!tn->tn_lvalue) {
+		if (tn->tn_op == CVT && tn->tn_cast &&
+		    tn->tn_left->tn_op == LOAD) {
+			if (tn->tn_type->t_tspec == PTR)
 				return true;
 			/* a cast does not yield an lvalue */
 			error(163);
@@ -701,7 +707,7 @@ typeok_incdec(mod_t *const mp, tnode_t *
 		/* %soperand of '%s' must be lvalue */
 		error(114, "", mp->m_name);
 		return false;
-	} else if (ltp->t_const) {
+	} else if (tp->t_const) {
 		if (!tflag)
 			/* %soperand of '%s' must be modifiable ... */
 			warning(115, "", mp->m_name);
@@ -710,15 +716,15 @@ typeok_incdec(mod_t *const mp, tnode_t *
 }
 
 static bool
-typeok_amper(mod_t *const mp,
-	     tnode_t *const ln, type_t *const ltp, tspec_t const lt)
+typeok_amper(const mod_t *mp,
+	     const tnode_t *tn, const type_t *tp, tspec_t t)
 {
-	if (lt == ARRAY || lt == FUNC) {
+	if (t == ARRAY || t == FUNC) {
 		/* ok, a warning comes later (in build_ampersand()) */
-	} else if (!ln->tn_lvalue) {
-		if (ln->tn_op == CVT && ln->tn_cast &&
-		    ln->tn_left->tn_op == LOAD) {
-			if (ln->tn_type->t_tspec == PTR)
+	} else if (!tn->tn_lvalue) {
+		if (tn->tn_op == CVT && tn->tn_cast &&
+		    tn->tn_left->tn_op == LOAD) {
+			if (tn->tn_type->t_tspec == PTR)
 				return true;
 			/* a cast does not yield an lvalue */
 			error(163);
@@ -726,30 +732,30 @@ typeok_amper(mod_t *const mp,
 		/* %soperand of '%s' must be lvalue */
 		error(114, "", mp->m_name);
 		return false;
-	} else if (is_scalar(lt)) {
-		if (ltp->t_bitfield) {
+	} else if (is_scalar(t)) {
+		if (tp->t_bitfield) {
 			/* cannot take address of bit-field */
 			error(112);
 			return false;
 		}
-	} else if (lt != STRUCT && lt != UNION) {
+	} else if (t != STRUCT && t != UNION) {
 		/* unacceptable operand of '%s' */
 		error(111, mp->m_name);
 		return false;
 	}
-	if (ln->tn_op == NAME && ln->tn_sym->s_reg) {
+	if (tn->tn_op == NAME && tn->tn_sym->s_reg) {
 		/* cannot take address of register %s */
-		error(113, ln->tn_sym->s_name);
+		error(113, tn->tn_sym->s_name);
 		return false;
 	}
 	return true;
 }
 
 static bool
-typeok_star(tspec_t lt)
+typeok_star(tspec_t t)
 {
 	/* until now there were no type checks for this operator */
-	if (lt != PTR) {
+	if (t != PTR) {
 		/* cannot dereference non-pointer type */
 		error(96);
 		return false;
@@ -769,7 +775,9 @@ typeok_plus(op_t op, tspec_t lt, tspec_t
 }
 
 static bool
-typeok_minus(op_t op, type_t *ltp, tspec_t lt, type_t *rtp, tspec_t rt)
+typeok_minus(op_t op,
+	     const type_t *ltp, tspec_t lt,
+	     const type_t *rtp, tspec_t rt)
 {
 	/* operands have scalar types (checked above) */
 	if (lt == PTR && (!is_integer(rt) && rt != PTR)) {
@@ -797,7 +805,9 @@ before_promotion_and_balancing(const tno
 }
 
 static void
-typeok_shr(mod_t *mp, tnode_t *ln, tspec_t lt, tnode_t *rn, tspec_t rt)
+typeok_shr(const mod_t *mp,
+	   const tnode_t *ln, tspec_t lt,
+	   const tnode_t *rn, tspec_t rt)
 {
 	tspec_t olt, ort;
 
@@ -842,7 +852,7 @@ typeok_shr(mod_t *mp, tnode_t *ln, tspec
 }
 
 static void
-typeok_shl(mod_t *mp, tspec_t lt, tspec_t rt) {
+typeok_shl(const mod_t *mp, tspec_t lt, tspec_t rt) {
 	/*
 	 * ANSI C does not perform balancing for shift operations,
 	 * but traditional C does. If the width of the right operand
@@ -864,7 +874,7 @@ typeok_shl(mod_t *mp, tspec_t lt, tspec_
 }
 
 static void
-typeok_shift(tspec_t lt, tnode_t *rn, tspec_t rt)
+typeok_shift(tspec_t lt, const tnode_t *rn, tspec_t rt)
 {
 	if (rn->tn_op == CON) {
 		if (!is_uinteger(rt) && rn->tn_val->v_quad < 0) {
@@ -881,7 +891,7 @@ typeok_shift(tspec_t lt, tnode_t *rn, ts
 }
 
 static bool
-typeok_eq(tnode_t *ln, tspec_t lt, tnode_t *rn, tspec_t rt)
+typeok_eq(const tnode_t *ln, tspec_t lt, const tnode_t *rn, tspec_t rt)
 {
 	if (lt == PTR && ((rt == PTR && rn->tn_type->t_tspec == VOID) ||
 			  is_integer(rt))) {
@@ -897,9 +907,9 @@ typeok_eq(tnode_t *ln, tspec_t lt, tnode
 }
 
 static bool
-typeok_ordered_comparison(op_t op, mod_t *mp,
-			  tnode_t *ln, type_t *ltp, tspec_t lt,
-			  tnode_t *rn, type_t *rtp, tspec_t rt)
+typeok_ordered_comparison(op_t op, const mod_t *mp,
+			  const tnode_t *ln, const type_t *ltp, tspec_t lt,
+			  const tnode_t *rn, const type_t *rtp, tspec_t rt)
 {
 	if ((lt == PTR || rt == PTR) && lt != rt) {
 		if (is_integer(lt) || is_integer(rt)) {
@@ -921,7 +931,7 @@ typeok_ordered_comparison(op_t op, mod_t
 }
 
 static bool
-typeok_quest(tspec_t lt, tnode_t **rn)
+typeok_quest(tspec_t lt, const tnode_t **rn)
 {
 	if (!is_scalar(lt)) {
 		/* first operand must have scalar type, op ? : */
@@ -935,9 +945,9 @@ typeok_quest(tspec_t lt, tnode_t **rn)
 }
 
 static bool
-typeok_colon(mod_t *mp,
-	     tnode_t *ln, type_t *ltp, tspec_t lt,
-	     tnode_t *rn, type_t *rtp, tspec_t rt)
+typeok_colon(const mod_t *mp,
+	     const tnode_t *ln, const type_t *ltp, tspec_t lt,
+	     const tnode_t *rn, const type_t *rtp, tspec_t rt)
 {
 	type_t *lstp, *rstp;
 	tspec_t lst, rst;
@@ -1005,7 +1015,7 @@ typeok_colon(mod_t *mp,
 }
 
 static bool
-typeok_assign(mod_t *mp, tnode_t *ln, type_t *ltp, tspec_t lt)
+typeok_assign(const mod_t *mp, const tnode_t *ln, const type_t *ltp, tspec_t lt)
 {
 	if (!ln->tn_lvalue) {
 		if (ln->tn_op == CVT && ln->tn_cast &&
@@ -1035,7 +1045,7 @@ typeok_assign(mod_t *mp, tnode_t *ln, ty
  * If the types are ok, typeok() returns 1, otherwise 0.
  */
 bool
-typeok(op_t op, int arg, tnode_t *ln, tnode_t *rn)
+typeok(op_t op, int arg, const tnode_t *ln, const tnode_t *rn)
 {
 	mod_t	*mp;
 	tspec_t	lt, rt;
@@ -1245,7 +1255,7 @@ typeok(op_t op, int arg, tnode_t *ln, tn
 }
 
 static void
-check_pointer_comparison(op_t op, tnode_t *ln, tnode_t *rn)
+check_pointer_comparison(op_t op, const tnode_t *ln, const tnode_t *rn)
 {
 	type_t	*ltp, *rtp;
 	tspec_t	lt, rt;
@@ -1283,7 +1293,8 @@ check_pointer_comparison(op_t op, tnode_
  * If the types are (almost) compatible, 1 is returned, otherwise 0.
  */
 static int
-check_assign_types_compatible(op_t op, int arg, tnode_t *ln, tnode_t *rn)
+check_assign_types_compatible(op_t op, int arg,
+			      const tnode_t *ln, const tnode_t *rn)
 {
 	tspec_t	lt, rt, lst = NOTSPEC, rst = NOTSPEC;
 	type_t	*ltp, *rtp, *lstp = NULL, *rstp = NULL;
@@ -1431,7 +1442,7 @@ check_assign_types_compatible(op_t op, i
  * enum type, is applied to an enum type.
  */
 static void
-check_bad_enum_operation(op_t op, tnode_t *ln, tnode_t *rn)
+check_bad_enum_operation(op_t op, const tnode_t *ln, const tnode_t *rn)
 {
 	mod_t	*mp;
 
@@ -1464,7 +1475,7 @@ check_bad_enum_operation(op_t op, tnode_
  * Prints a warning if an operator is applied to two different enum types.
  */
 static void
-check_enum_type_mismatch(op_t op, int arg, tnode_t *ln, tnode_t *rn)
+check_enum_type_mismatch(op_t op, int arg, const tnode_t *ln, const tnode_t *rn)
 {
 	mod_t	*mp;
 
@@ -1502,7 +1513,7 @@ check_enum_type_mismatch(op_t op, int ar
  * types.
  */
 static void
-check_enum_int_mismatch(op_t op, int arg, tnode_t *ln, tnode_t *rn)
+check_enum_int_mismatch(op_t op, int arg, const tnode_t *ln, const tnode_t *rn)
 {
 
 	if (!eflag)
@@ -2303,7 +2314,8 @@ warn_incompatible_types(op_t op, tspec_t
  * Print an appropriate warning.
  */
 static void
-warn_incompatible_pointers(mod_t *mp, type_t *ltp, type_t *rtp)
+warn_incompatible_pointers(const mod_t *mp,
+			   const type_t *ltp, const type_t *rtp)
 {
 	tspec_t	lt, rt;
 
@@ -2364,8 +2376,8 @@ merge_qualifiers(type_t **tpp, type_t *t
  * Returns 1 if the given structure or union has a constant member
  * (maybe recursively).
  */
-static int
-has_constant_member(type_t *tp)
+static bool
+has_constant_member(const type_t *tp)
 {
 	sym_t	*m;
 	tspec_t	t;
@@ -2375,13 +2387,13 @@ has_constant_member(type_t *tp)
 	for (m = tp->t_str->memb; m != NULL; m = m->s_next) {
 		tp = m->s_type;
 		if (tp->t_const)
-			return 1;
+			return true;
 		if ((t = tp->t_tspec) == STRUCT || t == UNION) {
 			if (has_constant_member(m->s_type))
-				return 1;
+				return true;
 		}
 	}
-	return 0;
+	return false;
 }
 
 /*
@@ -3571,7 +3583,7 @@ expr(tnode_t *tn, int vctx, int tctx, in
 }
 
 static void
-check_null_effect(tnode_t *tn)
+check_null_effect(const tnode_t *tn)
 {
 
 	if (!hflag)
@@ -3618,7 +3630,7 @@ check_null_effect(tnode_t *tn)
  * only used for debugging
  */
 static void
-display_expression(tnode_t *tn, int offs)
+display_expression(const tnode_t *tn, int offs)
 {
 	uint64_t uq;
 
@@ -3675,8 +3687,8 @@ display_expression(tnode_t *tn, int offs
  */
 /* ARGSUSED */
 void
-check_expr_misc(tnode_t *tn, int vctx, int tctx, int eqwarn, int fcall, int rvdisc,
-	int szof)
+check_expr_misc(const tnode_t *tn, int vctx, int tctx,
+		int eqwarn, int fcall, int rvdisc, int szof)
 {
 	tnode_t	*ln, *rn;
 	mod_t	*mp;

Reply via email to