Module Name:    src
Committed By:   rillig
Date:           Sun Apr 18 09:07:36 UTC 2021

Modified Files:
        src/usr.bin/xlint/lint1: decl.c

Log Message:
lint: migrate check_tag_usage to warning_at

This one is already a little trickier since it does not restore the
original curr_pos.  This function is only called in a few places, and
these either restore curr_pos themselves or only call functions
afterwards that immediately overwrite curr_pos.

Except for lint_assert, which may now report a different location.

The call to check_global_variable that is related to check_tag_usage was
the function that started this whole refactoring since its lint_assert
reported a completely wrong location when using a compound literal in an
initializer expression at block level 0.


To generate a diff of this commit:
cvs rdiff -u -r1.173 -r1.174 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.173 src/usr.bin/xlint/lint1/decl.c:1.174
--- src/usr.bin/xlint/lint1/decl.c:1.173	Sun Apr 18 08:57:57 2021
+++ src/usr.bin/xlint/lint1/decl.c	Sun Apr 18 09:07:36 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.173 2021/04/18 08:57:57 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.174 2021/04/18 09:07:36 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.173 2021/04/18 08:57:57 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.174 2021/04/18 09:07:36 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -3142,19 +3142,18 @@ check_tag_usage(sym_t *sym)
 	if (!zflag || dcs->d_ctx != EXTERN)
 		return;
 
-	curr_pos = sym->s_def_pos;
 	switch (sym->s_type->t_tspec) {
 	case STRUCT:
 		/* struct %s never defined */
-		warning(233, sym->s_name);
+		warning_at(233, sym->s_def_pos, sym->s_name);
 		break;
 	case UNION:
 		/* union %s never defined */
-		warning(234, sym->s_name);
+		warning_at(234, sym->s_def_pos, sym->s_name);
 		break;
 	case ENUM:
 		/* enum %s never defined */
-		warning(235, sym->s_name);
+		warning_at(235, sym->s_def_pos, sym->s_name);
 		break;
 	default:
 		lint_assert(/*CONSTCOND*/false);

Reply via email to