Module Name: src Committed By: rillig Date: Sun Apr 18 09:20:43 UTC 2021
Modified Files: src/usr.bin/xlint/lint1: decl.c Log Message: lint: do not modify curr_pos in check_global_symbols No functional change. To generate a diff of this commit: cvs rdiff -u -r1.175 -r1.176 src/usr.bin/xlint/lint1/decl.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.175 src/usr.bin/xlint/lint1/decl.c:1.176 --- src/usr.bin/xlint/lint1/decl.c:1.175 Sun Apr 18 09:15:16 2021 +++ src/usr.bin/xlint/lint1/decl.c Sun Apr 18 09:20:43 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.175 2021/04/18 09:15:16 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.176 2021/04/18 09:20:43 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.175 2021/04/18 09:15:16 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.176 2021/04/18 09:20:43 rillig Exp $"); #endif #include <sys/param.h> @@ -3172,13 +3172,10 @@ void check_global_symbols(void) { sym_t *sym; - pos_t cpos; if (block_level != 0 || dcs->d_next != NULL) norecover(); - cpos = curr_pos; - for (sym = dcs->d_dlsyms; sym != NULL; sym = sym->s_dlnxt) { if (sym->s_block_level == -1) continue; @@ -3190,29 +3187,26 @@ check_global_symbols(void) lint_assert(sym->s_kind == FMEMBER); } } - - curr_pos = cpos; } static void check_unused_static_global_variable(const sym_t *sym) { - curr_pos = sym->s_def_pos; if (sym->s_type->t_tspec == FUNC) { if (sym->s_def == DEF) { if (!sym->s_inline) /* static function %s unused */ - warning(236, sym->s_name); + warning_at(236, sym->s_def_pos, sym->s_name); } else { /* static function %s declared but not defined */ - warning(290, sym->s_name); + warning_at(290, sym->s_def_pos, sym->s_name); } } else if (!sym->s_set) { /* static variable %s unused */ - warning(226, sym->s_name); + warning_at(226, sym->s_def_pos, sym->s_name); } else { /* static variable %s set but not used */ - warning(307, sym->s_name); + warning_at(307, sym->s_def_pos, sym->s_name); } } @@ -3220,18 +3214,16 @@ static void check_static_global_variable(const sym_t *sym) { if (sym->s_type->t_tspec == FUNC && sym->s_used && sym->s_def != DEF) { - curr_pos = sym->s_use_pos; /* static function called but not defined: %s() */ - error(225, sym->s_name); + error_at(225, sym->s_use_pos, sym->s_name); } if (!sym->s_used) check_unused_static_global_variable(sym); if (!tflag && sym->s_def == TDEF && sym->s_type->t_const) { - curr_pos = sym->s_def_pos; /* const object %s should have initializer */ - warning(227, sym->s_name); + warning_at(227, sym->s_def_pos, sym->s_name); } }