Module Name:    src
Committed By:   rillig
Date:           Thu Jan 14 07:42:31 UTC 2021

Modified Files:
        src/tests/usr.bin/xlint/lint1: msg_156.exp
        src/usr.bin/xlint/lint1: err.c tree.c

Log Message:
lint: add type details to message for enum type mismatch

Before December 2020, it was cumbersome to add type information to a
message since the caller had to explicitly allocate buffers for the type
names.  That's probably the reason why this crucial detail had been left
out of the warning.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_156.exp
cvs rdiff -u -r1.66 -r1.67 src/usr.bin/xlint/lint1/err.c
cvs rdiff -u -r1.151 -r1.152 src/usr.bin/xlint/lint1/tree.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_156.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_156.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_156.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_156.exp:1.2	Fri Jan  8 21:25:03 2021
+++ src/tests/usr.bin/xlint/lint1/msg_156.exp	Thu Jan 14 07:42:31 2021
@@ -1 +1 @@
-msg_156.c(24): warning: enum type mismatch, arg #1 [156]
+msg_156.c(24): warning: enum type mismatch, arg #1 (enum color != enum size) [156]

Index: src/usr.bin/xlint/lint1/err.c
diff -u src/usr.bin/xlint/lint1/err.c:1.66 src/usr.bin/xlint/lint1/err.c:1.67
--- src/usr.bin/xlint/lint1/err.c:1.66	Tue Jan 12 20:42:01 2021
+++ src/usr.bin/xlint/lint1/err.c	Thu Jan 14 07:42:31 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: err.c,v 1.66 2021/01/12 20:42:01 rillig Exp $	*/
+/*	$NetBSD: err.c,v 1.67 2021/01/14 07:42:31 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.66 2021/01/12 20:42:01 rillig Exp $");
+__RCSID("$NetBSD: err.c,v 1.67 2021/01/14 07:42:31 rillig Exp $");
 #endif
 
 #include <sys/types.h>
@@ -215,7 +215,7 @@ const	char *msgs[] = {
 	"argument has incompatible pointer type, arg #%d (%s != %s)", /* 153 */
 	"illegal combination of %s (%s) and %s (%s), arg #%d",	      /* 154 */
 	"argument is incompatible with prototype, arg #%d",	      /* 155 */
-	"enum type mismatch, arg #%d",				      /* 156 */
+	"enum type mismatch, arg #%d (%s != %s)",		      /* 156 */
 	"ANSI C treats constant as unsigned",			      /* 157 */
 	"%s may be used before set",				      /* 158 */
 	"assignment in conditional context",			      /* 159 */

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.151 src/usr.bin/xlint/lint1/tree.c:1.152
--- src/usr.bin/xlint/lint1/tree.c:1.151	Tue Jan 12 20:42:01 2021
+++ src/usr.bin/xlint/lint1/tree.c	Thu Jan 14 07:42:31 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.151 2021/01/12 20:42:01 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.152 2021/01/14 07:42:31 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.151 2021/01/12 20:42:01 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.152 2021/01/14 07:42:31 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -1675,8 +1675,9 @@ check_enum_type_mismatch(op_t op, int ar
 			warning(210);
 			break;
 		case FARG:
-			/* enum type mismatch, arg #%d */
-			warning(156, arg);
+			/* enum type mismatch, arg #%d (%s != %s) */
+			warning(156, arg,
+			    type_name(ln->tn_type), type_name(rn->tn_type));
 			break;
 		case RETURN:
 			/* return value type mismatch (%s) and (%s) */

Reply via email to