Module Name: src
Committed By: rillig
Date: Sun Apr 18 07:31:47 UTC 2021
Modified Files:
src/tests/usr.bin/xlint/lint1: msg_260.c msg_260.exp
src/usr.bin/xlint/lint1: lint1.h
Log Message:
lint: document wrong location information in diagnostics
To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_260.c \
src/tests/usr.bin/xlint/lint1/msg_260.exp
cvs rdiff -u -r1.95 -r1.96 src/usr.bin/xlint/lint1/lint1.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/tests/usr.bin/xlint/lint1/msg_260.c
diff -u src/tests/usr.bin/xlint/lint1/msg_260.c:1.2 src/tests/usr.bin/xlint/lint1/msg_260.c:1.3
--- src/tests/usr.bin/xlint/lint1/msg_260.c:1.2 Sun Feb 21 09:07:58 2021
+++ src/tests/usr.bin/xlint/lint1/msg_260.c Sun Apr 18 07:31:47 2021
@@ -1,7 +1,29 @@
-/* $NetBSD: msg_260.c,v 1.2 2021/02/21 09:07:58 rillig Exp $ */
+/* $NetBSD: msg_260.c,v 1.3 2021/04/18 07:31:47 rillig Exp $ */
# 3 "msg_260.c"
// Test for message: previous declaration of %s [260]
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+/* lint1-extra-flags: -r */
+
+# 100 "header.h" 1
+struct s { /* expect: 260 */
+ int member;
+};
+# 13 "msg_260.c" 2
+
+# 200 "header.h" 1
+union s { /* expect: tag redeclared *//* expect: 260 */
+ int member;
+};
+/*
+ * FIXME: the stack trace for the 260 is wrong, as the 260 is included from
+ * line 8, not from line 14.
+ */
+# 19 "msg_160.c" 2
+
+union s { /* expect: tag redeclared */
+ int member;
+};
+/*
+ * FIXME: the stack trace for the 260 is missing.
+ */
Index: src/tests/usr.bin/xlint/lint1/msg_260.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_260.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_260.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_260.exp:1.2 Sun Mar 21 20:45:00 2021
+++ src/tests/usr.bin/xlint/lint1/msg_260.exp Sun Apr 18 07:31:47 2021
@@ -1 +1,6 @@
-msg_260.c(6): error: syntax error ':' [249]
+header.h(200): error: (struct) tag redeclared [46]
+ included from msg_260.c(14)
+header.h(100): previous declaration of s [260]
+ included from msg_260.c(14)
+msg_160.c(20): error: (union) tag redeclared [46]
+header.h(200): previous declaration of s [260]
Index: src/usr.bin/xlint/lint1/lint1.h
diff -u src/usr.bin/xlint/lint1/lint1.h:1.95 src/usr.bin/xlint/lint1/lint1.h:1.96
--- src/usr.bin/xlint/lint1/lint1.h:1.95 Wed Apr 14 18:35:40 2021
+++ src/usr.bin/xlint/lint1/lint1.h Sun Apr 18 07:31:47 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: lint1.h,v 1.95 2021/04/14 18:35:40 rillig Exp $ */
+/* $NetBSD: lint1.h,v 1.96 2021/04/18 07:31:47 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -57,6 +57,11 @@
/*
* Describes the position of a declaration or anything else.
+ *
+ * FIXME: Just a single file:lineno pair is not enough to accurately describe
+ * the position of a symbol. The whole inclusion path at that point must be
+ * stored as well. This makes a difference for symbols from included
+ * headers, see print_stack_trace.
*/
typedef struct {
const char *p_file;