Module Name:    src
Committed By:   rillig
Date:           Sat Jan 30 21:58:04 UTC 2021

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

Log Message:
lint: add type information to message 275

Before: cast discards 'const' from pointer target type
After:  cast discards 'const' from type 'pointer to const char'

Seen in sqlite3.c.


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 src/usr.bin/xlint/lint1/err.c
cvs rdiff -u -r1.195 -r1.196 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/usr.bin/xlint/lint1/err.c
diff -u src/usr.bin/xlint/lint1/err.c:1.71 src/usr.bin/xlint/lint1/err.c:1.72
--- src/usr.bin/xlint/lint1/err.c:1.71	Sat Jan 30 21:49:08 2021
+++ src/usr.bin/xlint/lint1/err.c	Sat Jan 30 21:58:04 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: err.c,v 1.71 2021/01/30 21:49:08 rillig Exp $	*/
+/*	$NetBSD: err.c,v 1.72 2021/01/30 21:58:04 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.71 2021/01/30 21:49:08 rillig Exp $");
+__RCSID("$NetBSD: err.c,v 1.72 2021/01/30 21:58:04 rillig Exp $");
 #endif
 
 #include <sys/types.h>
@@ -334,7 +334,7 @@ const	char *msgs[] = {
 	"empty translation unit",				      /* 272 */
 	"bit-field type '%s' invalid in ANSI C",		      /* 273 */
 	"ANSI C forbids comparison of %s with %s",		      /* 274 */
-	"cast discards 'const' from pointer target type",	      /* 275 */
+	"cast discards 'const' from type '%s'",			      /* 275 */
 	"__%s__ is illegal for type %s",			      /* 276 */
 	"initialisation of '%s' with '%s'",			      /* 277 */
 	"combination of '%s' and '%s', arg #%d",		      /* 278 */

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.195 src/usr.bin/xlint/lint1/tree.c:1.196
--- src/usr.bin/xlint/lint1/tree.c:1.195	Sat Jan 30 21:49:08 2021
+++ src/usr.bin/xlint/lint1/tree.c	Sat Jan 30 21:58:04 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.195 2021/01/30 21:49:08 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.196 2021/01/30 21:58:04 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.195 2021/01/30 21:49:08 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.196 2021/01/30 21:58:04 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -3489,8 +3489,8 @@ cast(tnode_t *tn, type_t *tp)
 	} else if (nt == PTR && ot == PTR) {
 		if (!tp->t_subt->t_const && tn->tn_type->t_subt->t_const) {
 			if (hflag)
-				/* cast discards 'const' from pointer tar... */
-				warning(275);
+				/* cast discards 'const' from type '%s' */
+				warning(275, type_name(tn->tn_type));
 		}
 	} else {
 		/* invalid cast expression */

Reply via email to