Module Name:    src
Committed By:   rillig
Date:           Sun Jan 24 11:21:58 UTC 2021

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

Log Message:
lint: fix wrong warning about null pointer comparison


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/msg_124.c
cvs rdiff -u -r1.8 -r1.9 src/tests/usr.bin/xlint/lint1/msg_124.exp
cvs rdiff -u -r1.188 -r1.189 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_124.c
diff -u src/tests/usr.bin/xlint/lint1/msg_124.c:1.5 src/tests/usr.bin/xlint/lint1/msg_124.c:1.6
--- src/tests/usr.bin/xlint/lint1/msg_124.c:1.5	Sun Jan 24 11:17:44 2021
+++ src/tests/usr.bin/xlint/lint1/msg_124.c	Sun Jan 24 11:21:58 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_124.c,v 1.5 2021/01/24 11:17:44 rillig Exp $	*/
+/*	$NetBSD: msg_124.c,v 1.6 2021/01/24 11:21:58 rillig Exp $	*/
 # 3 "msg_124.c"
 
 // Test for message: illegal pointer combination, op %s [124]
@@ -35,11 +35,11 @@ compare_pointers(const void *vp, const c
 	ok(vp == (void *)0);
 	ok(cp == (void *)0);
 	ok(ip == (void *)0);
-	ok(fp == (void *)0);	/*FIXME*//* expect: 274 */
+	ok(fp == (void *)0);	/* wrong 124 before 2021-01-25 */
 	ok((void *)0 == vp);
 	ok((void *)0 == cp);
 	ok((void *)0 == ip);
-	ok((void *)0 == fp);	/*FIXME*//* expect: 274 */
+	ok((void *)0 == fp);	/* wrong 124 before 2021-01-25 */
 	ok(vp == 0);
 	ok(cp == 0);
 	ok(ip == 0);

Index: src/tests/usr.bin/xlint/lint1/msg_124.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_124.exp:1.8 src/tests/usr.bin/xlint/lint1/msg_124.exp:1.9
--- src/tests/usr.bin/xlint/lint1/msg_124.exp:1.8	Sun Jan 24 11:17:44 2021
+++ src/tests/usr.bin/xlint/lint1/msg_124.exp	Sun Jan 24 11:21:58 2021
@@ -4,5 +4,3 @@ msg_124.c(20): warning: illegal pointer 
 msg_124.c(32): warning: ANSI C forbids comparison of 'void *' with function pointer [274]
 msg_124.c(33): warning: illegal pointer combination (pointer to const char) and (pointer to const int), op == [124]
 msg_124.c(34): warning: illegal pointer combination (pointer to const char) and (pointer to function(int) returning void), op == [124]
-msg_124.c(38): warning: ANSI C forbids comparison of function pointer with 'void *' [274]
-msg_124.c(42): warning: ANSI C forbids comparison of 'void *' with function pointer [274]

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.188 src/usr.bin/xlint/lint1/tree.c:1.189
--- src/usr.bin/xlint/lint1/tree.c:1.188	Sun Jan 24 10:57:17 2021
+++ src/usr.bin/xlint/lint1/tree.c	Sun Jan 24 11:21:58 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.188 2021/01/24 10:57:17 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.189 2021/01/24 11:21:58 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.188 2021/01/24 10:57:17 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.189 2021/01/24 11:21:58 rillig Exp $");
 #endif
 
 #include <float.h>
@@ -952,14 +952,12 @@ typeok_shift(tspec_t lt, const tnode_t *
 static bool
 is_typeok_eq(const tnode_t *ln, tspec_t lt, const tnode_t *rn, tspec_t rt)
 {
-	/* FIXME: missing tn_subt */
-	if (lt == PTR && ((rt == PTR && rn->tn_type->t_tspec == VOID) ||
+	if (lt == PTR && ((rt == PTR && rn->tn_type->t_subt->t_tspec == VOID) ||
 			  is_integer(rt))) {
 		if (rn->tn_op == CON && rn->tn_val->v_quad == 0)
 			return true;
 	}
-	/* FIXME: missing tn_subt */
-	if (rt == PTR && ((lt == PTR && ln->tn_type->t_tspec == VOID) ||
+	if (rt == PTR && ((lt == PTR && ln->tn_type->t_subt->t_tspec == VOID) ||
 			  is_integer(lt))) {
 		if (ln->tn_op == CON && ln->tn_val->v_quad == 0)
 			return true;

Reply via email to