Module Name:    src
Committed By:   rillig
Date:           Mon Aug 16 06:49:57 UTC 2021

Modified Files:
        src/tests/usr.bin/xlint/lint1: msg_046.c msg_046.exp msg_260.c
            msg_260.exp
        src/usr.bin/xlint/lint1: decl.c err.c

Log Message:
lint: add more details to message about redeclared tag


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_046.c \
    src/tests/usr.bin/xlint/lint1/msg_046.exp \
    src/tests/usr.bin/xlint/lint1/msg_260.c \
    src/tests/usr.bin/xlint/lint1/msg_260.exp
cvs rdiff -u -r1.221 -r1.222 src/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.136 -r1.137 src/usr.bin/xlint/lint1/err.c

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_046.c
diff -u src/tests/usr.bin/xlint/lint1/msg_046.c:1.3 src/tests/usr.bin/xlint/lint1/msg_046.c:1.4
--- src/tests/usr.bin/xlint/lint1/msg_046.c:1.3	Mon Aug 16 06:30:43 2021
+++ src/tests/usr.bin/xlint/lint1/msg_046.c	Mon Aug 16 06:49:57 2021
@@ -1,36 +1,36 @@
-/*	$NetBSD: msg_046.c,v 1.3 2021/08/16 06:30:43 rillig Exp $	*/
+/*	$NetBSD: msg_046.c,v 1.4 2021/08/16 06:49:57 rillig Exp $	*/
 # 3 "msg_046.c"
 
-// Test for message: (%s) tag redeclared [46]
+// Test for message: %s tag '%s' redeclared as %s [46]
 
 /* expect+1: warning: struct tag1 never defined [233] */
 struct tag1;
-/* expect+2: error: (struct) tag redeclared [46] */
+/* expect+2: error: struct tag 'tag1' redeclared as union [46] */
 /* expect+1: warning: union tag1 never defined [234] */
 union tag1;
 
 /* expect+1: warning: union tag2 never defined [234] */
 union tag2;
-/* expect+2: error: (union) tag redeclared [46] */
+/* expect+2: error: union tag 'tag2' redeclared as enum [46] */
 /* expect+1: warning: enum tag2 never defined [235] */
 enum tag2;
 
 /* expect+1: warning: enum tag3 never defined [235] */
 enum tag3;
-/* expect+2: error: (enum) tag redeclared [46] */
+/* expect+2: error: enum tag 'tag3' redeclared as struct [46] */
 /* expect+1: warning: struct tag3 never defined [233] */
 struct tag3;
 
-/* expect+2: error: (union) tag redeclared [46] */
+/* expect+2: error: union tag 'tag1' redeclared as struct [46] */
 /* expect+1: warning: struct tag1 never defined [233] */
 struct tag1 *use_tag1(void);
-/* expect+2: error: (enum) tag redeclared [46] */
+/* expect+2: error: enum tag 'tag2' redeclared as union [46] */
 /* expect+1: warning: union tag2 never defined [234] */
 union tag2 *use_tag2(void);
-/* expect+2: error: (struct) tag redeclared [46] */
+/* expect+2: error: struct tag 'tag3' redeclared as enum [46] */
 /* expect+1: warning: enum tag3 never defined [235] */
 enum tag3 *use_tag3(void);
 
-/* expect+2: error: (struct) tag redeclared [46] */
+/* expect+2: error: struct tag 'tag1' redeclared as union [46] */
 /* expect+1: warning: union tag1 never defined [234] */
 union tag1 *mismatch_tag1(void);
Index: src/tests/usr.bin/xlint/lint1/msg_046.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_046.exp:1.3 src/tests/usr.bin/xlint/lint1/msg_046.exp:1.4
--- src/tests/usr.bin/xlint/lint1/msg_046.exp:1.3	Mon Aug 16 06:30:43 2021
+++ src/tests/usr.bin/xlint/lint1/msg_046.exp	Mon Aug 16 06:49:57 2021
@@ -1,10 +1,10 @@
-msg_046.c(10): error: (struct) tag redeclared [46]
-msg_046.c(16): error: (union) tag redeclared [46]
-msg_046.c(22): error: (enum) tag redeclared [46]
-msg_046.c(26): error: (union) tag redeclared [46]
-msg_046.c(29): error: (enum) tag redeclared [46]
-msg_046.c(32): error: (struct) tag redeclared [46]
-msg_046.c(36): error: (struct) tag redeclared [46]
+msg_046.c(10): error: struct tag 'tag1' redeclared as union [46]
+msg_046.c(16): error: union tag 'tag2' redeclared as enum [46]
+msg_046.c(22): error: enum tag 'tag3' redeclared as struct [46]
+msg_046.c(26): error: union tag 'tag1' redeclared as struct [46]
+msg_046.c(29): error: enum tag 'tag2' redeclared as union [46]
+msg_046.c(32): error: struct tag 'tag3' redeclared as enum [46]
+msg_046.c(36): error: struct tag 'tag1' redeclared as union [46]
 msg_046.c(7): warning: struct tag1 never defined [233]
 msg_046.c(10): warning: union tag1 never defined [234]
 msg_046.c(13): warning: union tag2 never defined [234]
Index: src/tests/usr.bin/xlint/lint1/msg_260.c
diff -u src/tests/usr.bin/xlint/lint1/msg_260.c:1.3 src/tests/usr.bin/xlint/lint1/msg_260.c:1.4
--- src/tests/usr.bin/xlint/lint1/msg_260.c:1.3	Sun Apr 18 07:31:47 2021
+++ src/tests/usr.bin/xlint/lint1/msg_260.c	Mon Aug 16 06:49:57 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_260.c,v 1.3 2021/04/18 07:31:47 rillig Exp $	*/
+/*	$NetBSD: msg_260.c,v 1.4 2021/08/16 06:49:57 rillig Exp $	*/
 # 3 "msg_260.c"
 
 // Test for message: previous declaration of %s [260]
@@ -6,22 +6,26 @@
 /* lint1-extra-flags: -r */
 
 # 100 "header.h" 1
-struct s {		/* expect: 260 */
+/* expect+1: previous declaration of s [260] */
+struct s {
     int member;
 };
-# 13 "msg_260.c" 2
+# 14 "msg_260.c" 2
 
 # 200 "header.h" 1
-union s {		/* expect: tag redeclared *//* expect: 260 */
+/* expect+2: error: struct tag 's' redeclared as union [46] */
+/* expect+1: previous declaration of s [260] */
+union s {
     int member;
 };
 /*
- * FIXME: the stack trace for the 260 is wrong, as the 260 is included from
- * line 8, not from line 14.
+ * FIXME: the stack trace for the message 260 is wrong, as the previous
+ * declaration is included from logical line msg_260.c:8, not from
+ * msg_260.c:15.
  */
-# 19 "msg_160.c" 2
-
-union s {		/* expect: tag redeclared */
+# 27 "msg_260.c" 2
+/* expect+1: error: union tag 's' redeclared as union [46] */
+union s {
     int member;
 };
 /*
Index: src/tests/usr.bin/xlint/lint1/msg_260.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_260.exp:1.3 src/tests/usr.bin/xlint/lint1/msg_260.exp:1.4
--- src/tests/usr.bin/xlint/lint1/msg_260.exp:1.3	Sun Apr 18 07:31:47 2021
+++ src/tests/usr.bin/xlint/lint1/msg_260.exp	Mon Aug 16 06:49:57 2021
@@ -1,6 +1,6 @@
-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]
+header.h(202): error: struct tag 's' redeclared as union [46]
+	included from msg_260.c(15)
+header.h(101): previous declaration of s [260]
+	included from msg_260.c(15)
+msg_260.c(28): error: union tag 's' redeclared as union [46]
+header.h(202): previous declaration of s [260]

Index: src/usr.bin/xlint/lint1/decl.c
diff -u src/usr.bin/xlint/lint1/decl.c:1.221 src/usr.bin/xlint/lint1/decl.c:1.222
--- src/usr.bin/xlint/lint1/decl.c:1.221	Tue Aug 10 20:43:12 2021
+++ src/usr.bin/xlint/lint1/decl.c	Mon Aug 16 06:49:56 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.221 2021/08/10 20:43:12 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.222 2021/08/16 06:49:56 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.221 2021/08/10 20:43:12 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.222 2021/08/16 06:49:56 rillig Exp $");
 #endif
 
 #include <sys/param.h>
@@ -1776,14 +1776,16 @@ newtag(sym_t *tag, scl_t scl, bool decl,
 		}
 	} else {
 		if (tag->s_scl != scl) {
-			/* (%s) tag redeclared */
-			error(46, storage_class_name(tag->s_scl));
+			/* %s tag '%s' redeclared as %s */
+			error(46, storage_class_name(tag->s_scl),
+			    tag->s_name, storage_class_name(scl));
 			print_previous_declaration(-1, tag);
 			tag = pushdown(tag);
 			dcs->d_next->d_nonempty_decl = true;
 		} else if (decl && !is_incomplete(tag->s_type)) {
-			/* (%s) tag redeclared */
-			error(46, storage_class_name(tag->s_scl));
+			/* %s tag '%s' redeclared as %s */
+			error(46, storage_class_name(tag->s_scl),
+			    tag->s_name, storage_class_name(scl));
 			print_previous_declaration(-1, tag);
 			tag = pushdown(tag);
 			dcs->d_next->d_nonempty_decl = true;

Index: src/usr.bin/xlint/lint1/err.c
diff -u src/usr.bin/xlint/lint1/err.c:1.136 src/usr.bin/xlint/lint1/err.c:1.137
--- src/usr.bin/xlint/lint1/err.c:1.136	Sat Aug 14 13:00:55 2021
+++ src/usr.bin/xlint/lint1/err.c	Mon Aug 16 06:49:56 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: err.c,v 1.136 2021/08/14 13:00:55 rillig Exp $	*/
+/*	$NetBSD: err.c,v 1.137 2021/08/16 06:49:56 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: err.c,v 1.136 2021/08/14 13:00:55 rillig Exp $");
+__RCSID("$NetBSD: err.c,v 1.137 2021/08/16 06:49:56 rillig Exp $");
 #endif
 
 #include <sys/types.h>
@@ -100,7 +100,7 @@ const char *const msgs[] = {
 	"redefinition hides earlier one: %s",			      /* 43 */
 	"declaration introduces new type in ANSI C: %s %s",	      /* 44 */
 	"base type is really '%s %s'",				      /* 45 */
-	"(%s) tag redeclared",					      /* 46 */
+	"%s tag '%s' redeclared as %s",				      /* 46 */
 	"zero sized %s is a C9X feature",			      /* 47 */
 	"overflow in enumeration values: %s",			      /* 48 */
 	"anonymous struct/union members is a C9X feature",	      /* 49 */

Reply via email to