Module Name: src Committed By: rillig Date: Sun Jan 24 10:50:42 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: document bug in typeok_eq Since rt is an alias for rn->tn_type->t_tspec, it cannot be PTR and VOID at the same time. This makes the condition unsatisfiable. Removing that part of the code didn't show any change in behavior, as expected. It may even be that fixing this obvious bug doesn't show any change in behavior since that function is only used in a single place and check_pointer_comparison performs its own checks before issuing any warning. At least the test cases added to msg_124.c all run as expected. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_124.c cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/msg_124.exp cvs rdiff -u -r1.185 -r1.186 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.2 src/tests/usr.bin/xlint/lint1/msg_124.c:1.3 --- src/tests/usr.bin/xlint/lint1/msg_124.c:1.2 Sun Jan 3 15:44:35 2021 +++ src/tests/usr.bin/xlint/lint1/msg_124.c Sun Jan 24 10:50:42 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: msg_124.c,v 1.2 2021/01/03 15:44:35 rillig Exp $ */ +/* $NetBSD: msg_124.c,v 1.3 2021/01/24 10:50:42 rillig Exp $ */ # 3 "msg_124.c" // Test for message: illegal pointer combination, op %s [124] @@ -13,7 +13,33 @@ typedef int(*printflike)(const char *, . void example(int *ptr) { - signal_handler handler = ptr; - sys_signal signal = ptr; - printflike printf = ptr; + signal_handler handler = ptr; /* expect: 124 */ + sys_signal signal = ptr; /* expect: 124 */ + printflike printf = ptr; /* expect: 124 */ +} + +void ok(_Bool); +void not_ok(_Bool); + +void +compare_pointers(const void *vp, const char *cp, const int *ip, + signal_handler fp) +{ + ok(vp == cp); + ok(vp == ip); + ok(vp == fp); + not_ok(cp == ip); /* expect: 124 */ + not_ok(cp == fp); /* expect: 124 */ + ok(vp == (void *)0); + ok(cp == (void *)0); + ok(ip == (void *)0); + ok(fp == (void *)0); + ok(vp == 0); + ok(cp == 0); + ok(ip == 0); + ok(fp == 0); + ok(vp == 0L); + ok(cp == 0L); + ok(ip == 0L); + ok(fp == 0L); } Index: src/tests/usr.bin/xlint/lint1/msg_124.exp diff -u src/tests/usr.bin/xlint/lint1/msg_124.exp:1.5 src/tests/usr.bin/xlint/lint1/msg_124.exp:1.6 --- src/tests/usr.bin/xlint/lint1/msg_124.exp:1.5 Tue Jan 5 23:07:49 2021 +++ src/tests/usr.bin/xlint/lint1/msg_124.exp Sun Jan 24 10:50:42 2021 @@ -1,3 +1,5 @@ msg_124.c(16): warning: illegal pointer combination (pointer to function(int) returning void) and (pointer to int), op = [124] msg_124.c(17): warning: illegal pointer combination (pointer to function(pointer to function(int) returning void) returning pointer to function(int) returning void) and (pointer to int), op = [124] msg_124.c(18): warning: illegal pointer combination (pointer to function(pointer to const char, ...) returning int) and (pointer to int), op = [124] +msg_124.c(31): warning: illegal pointer combination (pointer to const char) and (pointer to const int), op == [124] +msg_124.c(32): warning: illegal pointer combination (pointer to const char) and (pointer to function(int) returning void), op == [124] Index: src/usr.bin/xlint/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.185 src/usr.bin/xlint/lint1/tree.c:1.186 --- src/usr.bin/xlint/lint1/tree.c:1.185 Sun Jan 24 00:15:20 2021 +++ src/usr.bin/xlint/lint1/tree.c Sun Jan 24 10:50:42 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: tree.c,v 1.185 2021/01/24 00:15:20 rillig Exp $ */ +/* $NetBSD: tree.c,v 1.186 2021/01/24 10:50:42 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.185 2021/01/24 00:15:20 rillig Exp $"); +__RCSID("$NetBSD: tree.c,v 1.186 2021/01/24 10:50:42 rillig Exp $"); #endif #include <float.h> @@ -952,11 +952,13 @@ typeok_shift(tspec_t lt, const tnode_t * static bool 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) || 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) || is_integer(lt))) { if (ln->tn_op == CON && ln->tn_val->v_quad == 0)