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: in check_global_variable_size, res...



details:   https://anonhg.NetBSD.org/src/rev/e21b6055d72f
branches:  trunk
changeset: 1020634:e21b6055d72f
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Apr 18 09:15:16 2021 +0000

description:
lint: in check_global_variable_size, restore curr_pos

This affects only calls to lint_assert, all other code stays
functionally the same.

diffstat:

 usr.bin/xlint/lint1/decl.c |  16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diffs (50 lines):

diff -r 2996ab0322b5 -r e21b6055d72f usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c        Sun Apr 18 09:07:36 2021 +0000
+++ b/usr.bin/xlint/lint1/decl.c        Sun Apr 18 09:15:16 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.174 2021/04/18 09:07:36 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.175 2021/04/18 09:15:16 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.174 2021/04/18 09:07:36 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.175 2021/04/18 09:15:16 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -3256,6 +3256,8 @@
 static void
 check_global_variable_size(const sym_t *sym)
 {
+       pos_t cpos;
+       int length_in_bits;
 
        if (sym->s_def != TDEF)
                return;
@@ -3266,15 +3268,19 @@
                 */
                return;
 
+       cpos = curr_pos;
        curr_pos = sym->s_def_pos;
-       if (length(sym->s_type, sym->s_name) == 0 &&
+       length_in_bits = length(sym->s_type, sym->s_name);
+       curr_pos = cpos;
+
+       if (length_in_bits == 0 &&
            sym->s_type->t_tspec == ARRAY && sym->s_type->t_dim == 0) {
                if (tflag || (sym->s_scl == EXTERN && !sflag)) {
                        /* empty array declaration: %s */
-                       warning(190, sym->s_name);
+                       warning_at(190, sym->s_def_pos, sym->s_name);
                } else {
                        /* empty array declaration: %s */
-                       error(190, sym->s_name);
+                       error_at(190, sym->s_def_pos, sym->s_name);
                }
        }
 }



Home | Main Index | Thread Index | Old Index