Module Name:    src
Committed By:   rillig
Date:           Sat Jun  3 20:28:54 UTC 2023

Modified Files:
        src/tests/usr.bin/xlint/lint1: msg_107.c msg_123.c msg_132.c
        src/usr.bin/xlint/lint1: tree.c

Log Message:
lint: provide more detailed types when operands do not match


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_107.c
cvs rdiff -u -r1.7 -r1.8 src/tests/usr.bin/xlint/lint1/msg_123.c
cvs rdiff -u -r1.30 -r1.31 src/tests/usr.bin/xlint/lint1/msg_132.c
cvs rdiff -u -r1.524 -r1.525 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_107.c
diff -u src/tests/usr.bin/xlint/lint1/msg_107.c:1.4 src/tests/usr.bin/xlint/lint1/msg_107.c:1.5
--- src/tests/usr.bin/xlint/lint1/msg_107.c:1.4	Sun Jun 19 12:14:34 2022
+++ src/tests/usr.bin/xlint/lint1/msg_107.c	Sat Jun  3 20:28:54 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_107.c,v 1.4 2022/06/19 12:14:34 rillig Exp $	*/
+/*	$NetBSD: msg_107.c,v 1.5 2023/06/03 20:28:54 rillig Exp $	*/
 # 3 "msg_107.c"
 
 // Test for message: operands of '%s' have incompatible types '%s' and '%s' [107]
@@ -7,6 +7,6 @@
 void
 compare(double d, void *ptr)
 {
-	/* expect+1: error: operands of '==' have incompatible types 'double' and 'pointer' [107] */
+	/* expect+1: error: operands of '==' have incompatible types 'double' and 'pointer to void' [107] */
 	return d == ptr;
 }

Index: src/tests/usr.bin/xlint/lint1/msg_123.c
diff -u src/tests/usr.bin/xlint/lint1/msg_123.c:1.7 src/tests/usr.bin/xlint/lint1/msg_123.c:1.8
--- src/tests/usr.bin/xlint/lint1/msg_123.c:1.7	Tue Mar 28 14:44:34 2023
+++ src/tests/usr.bin/xlint/lint1/msg_123.c	Sat Jun  3 20:28:54 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_123.c,v 1.7 2023/03/28 14:44:34 rillig Exp $	*/
+/*	$NetBSD: msg_123.c,v 1.8 2023/06/03 20:28:54 rillig Exp $	*/
 # 3 "msg_123.c"
 
 // Test for message: illegal combination of %s '%s' and %s '%s', op '%s' [123]
@@ -24,13 +24,13 @@ compare(_Bool b, int i, double d, const 
 	ok(d < b);
 	ok(d < i);
 	ok(d < d);
-	/* expect+1: error: operands of '<' have incompatible types 'double' and 'pointer' [107] */
+	/* expect+1: error: operands of '<' have incompatible types 'double' and 'pointer to const char' [107] */
 	bad(d < p);
 	/* expect+1: warning: illegal combination of pointer 'pointer to const char' and integer '_Bool', op '<' [123] */
 	bad(p < b);
 	/* expect+1: warning: illegal combination of pointer 'pointer to const char' and integer 'int', op '<' [123] */
 	bad(p < i);
-	/* expect+1: error: operands of '<' have incompatible types 'pointer' and 'double' [107] */
+	/* expect+1: error: operands of '<' have incompatible types 'pointer to const char' and 'double' [107] */
 	bad(p < d);
 	ok(p < p);
 }

Index: src/tests/usr.bin/xlint/lint1/msg_132.c
diff -u src/tests/usr.bin/xlint/lint1/msg_132.c:1.30 src/tests/usr.bin/xlint/lint1/msg_132.c:1.31
--- src/tests/usr.bin/xlint/lint1/msg_132.c:1.30	Tue May  9 15:51:33 2023
+++ src/tests/usr.bin/xlint/lint1/msg_132.c	Sat Jun  3 20:28:54 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_132.c,v 1.30 2023/05/09 15:51:33 rillig Exp $	*/
+/*	$NetBSD: msg_132.c,v 1.31 2023/06/03 20:28:54 rillig Exp $	*/
 # 3 "msg_132.c"
 
 // Test for message: conversion from '%s' to '%s' may lose accuracy [132]
@@ -174,7 +174,7 @@ to_bool(long a, long b)
 const char *
 cover_build_plus_minus(const char *arr, double idx)
 {
-	/* expect+3: error: operands of '+' have incompatible types 'pointer' and 'double' [107] */
+	/* expect+3: error: operands of '+' have incompatible types 'pointer to const char' and 'double' [107] */
 	/* expect+2: warning: function 'cover_build_plus_minus' expects to return value [214] */
 	if (idx > 0.0)
 		return arr + idx;

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.524 src/usr.bin/xlint/lint1/tree.c:1.525
--- src/usr.bin/xlint/lint1/tree.c:1.524	Mon May 22 12:55:04 2023
+++ src/usr.bin/xlint/lint1/tree.c	Sat Jun  3 20:28:54 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.524 2023/05/22 12:55:04 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.525 2023/06/03 20:28:54 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: tree.c,v 1.524 2023/05/22 12:55:04 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.525 2023/06/03 20:28:54 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -2203,7 +2203,7 @@ warn_incompatible_types(op_t op,
 		error(171, type_name(ltp), type_name(rtp));
 	} else if (mp->m_binary) {
 		/* operands of '%s' have incompatible types '%s' and '%s' */
-		error(107, mp->m_name, tspec_name(lt), tspec_name(rt));
+		error(107, mp->m_name, type_name(ltp), type_name(rtp));
 	} else {
 		lint_assert(rt == NO_TSPEC);
 		/* operand of '%s' has invalid type '%s' */

Reply via email to