Module Name:    src
Committed By:   christos
Date:           Mon Apr 13 21:17:37 UTC 2009

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

Log Message:
since we know the types, print what they are in error messages.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/usr.bin/xlint/lint1/err.c
cvs rdiff -u -r1.55 -r1.56 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.38 src/usr.bin/xlint/lint1/err.c:1.39
--- src/usr.bin/xlint/lint1/err.c:1.38	Thu Jul 31 11:21:34 2008
+++ src/usr.bin/xlint/lint1/err.c	Mon Apr 13 17:17:37 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: err.c,v 1.38 2008/07/31 15:21:34 christos Exp $	*/
+/*	$NetBSD: err.c,v 1.39 2009/04/13 21:17:37 christos 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.38 2008/07/31 15:21:34 christos Exp $");
+__RCSID("$NetBSD: err.c,v 1.39 2009/04/13 21:17:37 christos Exp $");
 #endif
 
 #include <sys/types.h>
@@ -187,7 +187,7 @@
 	"ANSI C forbids ordered comparisons of pointers to functions",/* 125 */
 	"incompatible types in conditional",			      /* 126 */
 	"'&' before array or function: ignored",		      /* 127 */
-	"operands have incompatible pointer types, op %s",	      /* 128 */
+	"operands have incompatible pointer types, op %s (%s != %s)", /* 128 */
 	"expression has null effect",				      /* 129 */
 	"enum type mismatch, op %s",				      /* 130 */
 	"conversion to '%s' may sign-extend incorrectly",	      /* 131 */
@@ -212,7 +212,7 @@
 	"argument mismatch: %d arg%s passed, %d expected",	      /* 150 */
 	"void expressions may not be arguments, arg #%d",	      /* 151 */
 	"argument cannot have unknown size, arg #%d",		      /* 152 */
-	"argument has incompatible pointer type, arg #%d",	      /* 153 */
+	"argument has incompatible pointer type, arg #%d (%s != %s)", /* 153 */
 	"illegal combination of pointer and integer, arg #%d",	      /* 154 */
 	"argument is incompatible with prototype, arg #%d",	      /* 155 */
 	"enum type mismatch, arg #%d",			       	      /* 156 */
@@ -241,7 +241,7 @@
 	"cannot initialize struct/union with no named member",	      /* 179 */
 	"bit-field initializer does not fit",			      /* 180 */
 	"{}-enclosed initializer required",			      /* 181 */
-	"incompatible pointer types",				      /* 182 */
+	"incompatible pointer types (%s != %s)",		      /* 182 */
 	"illegal combination of pointer and integer",		      /* 183 */
 	"illegal pointer combination",				      /* 184 */
 	"initialisation type mismatch",				      /* 185 */

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.55 src/usr.bin/xlint/lint1/tree.c:1.56
--- src/usr.bin/xlint/lint1/tree.c:1.55	Mon Mar  2 15:53:11 2009
+++ src/usr.bin/xlint/lint1/tree.c	Mon Apr 13 17:17:37 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.55 2009/03/02 20:53:11 christos Exp $	*/
+/*	$NetBSD: tree.c,v 1.56 2009/04/13 21:17:37 christos 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.55 2009/03/02 20:53:11 christos Exp $");
+__RCSID("$NetBSD: tree.c,v 1.56 2009/04/13 21:17:37 christos Exp $");
 #endif
 
 #include <stdlib.h>
@@ -1258,6 +1258,7 @@
 	type_t	*ltp, *rtp, *lstp = NULL, *rstp = NULL;
 	mod_t	*mp;
 	const	char *lts, *rts;
+	char lbuf[128], rbuf[128];
 
 	if ((lt = (ltp = ln->tn_type)->t_tspec) == PTR)
 		lst = (lstp = ltp->t_subt)->t_tspec;
@@ -1309,19 +1310,21 @@
 		    ((!lstp->t_const && rstp->t_const) ||
 		     (!lstp->t_volatile && rstp->t_volatile))) {
 			/* left side has not all qualifiers of right */
+			tyname(lbuf, sizeof(lbuf), lstp);
+			tyname(rbuf, sizeof(rbuf), lstp);
 			switch (op) {
 			case INIT:
 			case RETURN:
 				/* incompatible pointer types */
-				warning(182);
+				warning(182, lbuf, rbuf);
 				break;
 			case FARG:
 				/* argument has incompat. ptr. type, arg #%d */
-				warning(153, arg);
+				warning(153, arg, lbuf, rbuf);
 				break;
 			default:
 				/* operands have incompat. ptr. types, op %s */
-				warning(128, mp->m_name);
+				warning(128, mp->m_name, lbuf, rbuf);
 				break;
 			}
 		}
@@ -1355,7 +1358,8 @@
 			break;
 		case FARG:
 			/* argument has incompatible pointer type, arg #%d */
-			warning(153, arg);
+			warning(153, arg, tyname(lbuf, sizeof(lbuf), ltp),
+			    tyname(rbuf, sizeof(rbuf), rtp));
 			break;
 		default:
 			illptrc(mp, ltp, rtp);

Reply via email to