Sun Jan 3 15:51:16 2021 UTC ()
lint: add type information to message 124 "illegal pointer combination"


(rillig)
diff -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/d_long_double_int.exp
diff -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_124.exp
diff -r1.60 -r1.61 src/usr.bin/xlint/lint1/err.c
diff -r1.116 -r1.117 src/usr.bin/xlint/lint1/tree.c

cvs diff -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/Attic/d_long_double_int.exp (expand / switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/Attic/d_long_double_int.exp 2020/12/28 09:58:56 1.1
+++ src/tests/usr.bin/xlint/lint1/Attic/d_long_double_int.exp 2021/01/03 15:51:16 1.2

cvs diff -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/Attic/msg_124.exp (expand / switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/Attic/msg_124.exp 2021/01/03 15:44:35 1.2
+++ src/tests/usr.bin/xlint/lint1/Attic/msg_124.exp 2021/01/03 15:51:16 1.3
@@ -1,3 +1,3 @@ @@ -1,3 +1,3 @@
1msg_124.c(16): warning: illegal pointer combination, op p = p [124] 1msg_124.c(16): warning: illegal pointer combination (pointer to function) and (pointer to int), op p = p [124]
2msg_124.c(17): warning: illegal pointer combination, op p = p [124] 2msg_124.c(17): warning: illegal pointer combination (pointer to function) and (pointer to int), op p = p [124]
3msg_124.c(18): warning: illegal pointer combination, op p = p [124] 3msg_124.c(18): warning: illegal pointer combination (pointer to function) and (pointer to int), op p = p [124]

cvs diff -r1.60 -r1.61 src/usr.bin/xlint/lint1/err.c (expand / switch to unified diff)

--- src/usr.bin/xlint/lint1/err.c 2021/01/02 17:17:00 1.60
+++ src/usr.bin/xlint/lint1/err.c 2021/01/03 15:51:16 1.61
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: err.c,v 1.60 2021/01/02 17:17:00 rillig Exp $ */ 1/* $NetBSD: err.c,v 1.61 2021/01/03 15:51:16 rillig Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1994, 1995 Jochen Pohl 4 * Copyright (c) 1994, 1995 Jochen Pohl
5 * All Rights Reserved. 5 * All Rights Reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -27,27 +27,27 @@ @@ -27,27 +27,27 @@
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */ 32 */
33 33
34#if HAVE_NBTOOL_CONFIG_H 34#if HAVE_NBTOOL_CONFIG_H
35#include "nbtool_config.h" 35#include "nbtool_config.h"
36#endif 36#endif
37 37
38#include <sys/cdefs.h> 38#include <sys/cdefs.h>
39#if defined(__RCSID) && !defined(lint) 39#if defined(__RCSID) && !defined(lint)
40__RCSID("$NetBSD: err.c,v 1.60 2021/01/02 17:17:00 rillig Exp $"); 40__RCSID("$NetBSD: err.c,v 1.61 2021/01/03 15:51:16 rillig Exp $");
41#endif 41#endif
42 42
43#include <sys/types.h> 43#include <sys/types.h>
44#include <stdarg.h> 44#include <stdarg.h>
45#include <stdlib.h> 45#include <stdlib.h>
46 46
47#include "lint1.h" 47#include "lint1.h"
48 48
49/* number of errors found */ 49/* number of errors found */
50int nerr; 50int nerr;
51 51
52/* number of syntax errors */ 52/* number of syntax errors */
53int sytxerr; 53int sytxerr;
@@ -173,27 +173,27 @@ const char *msgs[] = { @@ -173,27 +173,27 @@ const char *msgs[] = {
173 "unacceptable operand of '%s'", /* 111 */ 173 "unacceptable operand of '%s'", /* 111 */
174 "cannot take address of bit-field", /* 112 */ 174 "cannot take address of bit-field", /* 112 */
175 "cannot take address of register %s", /* 113 */ 175 "cannot take address of register %s", /* 113 */
176 "%soperand of '%s' must be lvalue", /* 114 */ 176 "%soperand of '%s' must be lvalue", /* 114 */
177 "%soperand of '%s' must be modifiable lvalue", /* 115 */ 177 "%soperand of '%s' must be modifiable lvalue", /* 115 */
178 "illegal pointer subtraction", /* 116 */ 178 "illegal pointer subtraction", /* 116 */
179 "bitwise operation on signed value possibly nonportable", /* 117 */ 179 "bitwise operation on signed value possibly nonportable", /* 117 */
180 "semantics of '%s' change in ANSI C; use explicit cast", /* 118 */ 180 "semantics of '%s' change in ANSI C; use explicit cast", /* 118 */
181 "conversion of '%s' to '%s' is out of range", /* 119 */ 181 "conversion of '%s' to '%s' is out of range", /* 119 */
182 "bitwise operation on signed value nonportable", /* 120 */ 182 "bitwise operation on signed value nonportable", /* 120 */
183 "negative shift", /* 121 */ 183 "negative shift", /* 121 */
184 "shift greater than size of object", /* 122 */ 184 "shift greater than size of object", /* 122 */
185 "illegal combination of %s (%s) and %s (%s), op %s", /* 123 */ 185 "illegal combination of %s (%s) and %s (%s), op %s", /* 123 */
186 "illegal pointer combination, op %s", /* 124 */ 186 "illegal pointer combination (%s) and (%s), op %s", /* 124 */
187 "ANSI C forbids ordered comparisons of pointers to functions",/* 125 */ 187 "ANSI C forbids ordered comparisons of pointers to functions",/* 125 */
188 "incompatible types in conditional", /* 126 */ 188 "incompatible types in conditional", /* 126 */
189 "'&' before array or function: ignored", /* 127 */ 189 "'&' before array or function: ignored", /* 127 */
190 "operands have incompatible pointer types, op %s (%s != %s)", /* 128 */ 190 "operands have incompatible pointer types, op %s (%s != %s)", /* 128 */
191 "expression has null effect", /* 129 */ 191 "expression has null effect", /* 129 */
192 "enum type mismatch, op %s", /* 130 */ 192 "enum type mismatch, op %s", /* 130 */
193 "conversion to '%s' may sign-extend incorrectly", /* 131 */ 193 "conversion to '%s' may sign-extend incorrectly", /* 131 */
194 "conversion from '%s' to '%s' may lose accuracy", /* 132 */ 194 "conversion from '%s' to '%s' may lose accuracy", /* 132 */
195 "conversion of pointer to '%s' loses bits", /* 133 */ 195 "conversion of pointer to '%s' loses bits", /* 133 */
196 "conversion of pointer to '%s' may lose bits", /* 134 */ 196 "conversion of pointer to '%s' may lose bits", /* 134 */
197 "possible pointer alignment problem", /* 135 */ 197 "possible pointer alignment problem", /* 135 */
198 "cannot do pointer arithmetic on operand of unknown size", /* 136 */ 198 "cannot do pointer arithmetic on operand of unknown size", /* 136 */
199 "use of incomplete enum type, op %s", /* 137 */ 199 "use of incomplete enum type, op %s", /* 137 */

cvs diff -r1.116 -r1.117 src/usr.bin/xlint/lint1/tree.c (expand / switch to unified diff)

--- src/usr.bin/xlint/lint1/tree.c 2021/01/02 18:26:44 1.116
+++ src/usr.bin/xlint/lint1/tree.c 2021/01/03 15:51:16 1.117
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: tree.c,v 1.116 2021/01/02 18:26:44 rillig Exp $ */ 1/* $NetBSD: tree.c,v 1.117 2021/01/03 15:51:16 rillig Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1994, 1995 Jochen Pohl 4 * Copyright (c) 1994, 1995 Jochen Pohl
5 * All Rights Reserved. 5 * All Rights Reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -27,27 +27,27 @@ @@ -27,27 +27,27 @@
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */ 32 */
33 33
34#if HAVE_NBTOOL_CONFIG_H 34#if HAVE_NBTOOL_CONFIG_H
35#include "nbtool_config.h" 35#include "nbtool_config.h"
36#endif 36#endif
37 37
38#include <sys/cdefs.h> 38#include <sys/cdefs.h>
39#if defined(__RCSID) && !defined(lint) 39#if defined(__RCSID) && !defined(lint)
40__RCSID("$NetBSD: tree.c,v 1.116 2021/01/02 18:26:44 rillig Exp $"); 40__RCSID("$NetBSD: tree.c,v 1.117 2021/01/03 15:51:16 rillig Exp $");
41#endif 41#endif
42 42
43#include <float.h> 43#include <float.h>
44#include <limits.h> 44#include <limits.h>
45#include <math.h> 45#include <math.h>
46#include <signal.h> 46#include <signal.h>
47#include <stdlib.h> 47#include <stdlib.h>
48#include <string.h> 48#include <string.h>
49 49
50#include "lint1.h" 50#include "lint1.h"
51#include "cgram.h" 51#include "cgram.h"
52#include "externs1.h" 52#include "externs1.h"
53 53
@@ -2205,28 +2205,29 @@ warn_incompatible_pointers(mod_t *mp, ty @@ -2205,28 +2205,29 @@ warn_incompatible_pointers(mod_t *mp, ty
2205 if ((lt == STRUCT || lt == UNION) && (rt == STRUCT || rt == UNION)) { 2205 if ((lt == STRUCT || lt == UNION) && (rt == STRUCT || rt == UNION)) {
2206 if (mp == NULL) { 2206 if (mp == NULL) {
2207 /* illegal structure pointer combination */ 2207 /* illegal structure pointer combination */
2208 warning(244); 2208 warning(244);
2209 } else { 2209 } else {
2210 /* illegal structure pointer combination, op %s */ 2210 /* illegal structure pointer combination, op %s */
2211 warning(245, mp->m_name); 2211 warning(245, mp->m_name);
2212 } 2212 }
2213 } else { 2213 } else {
2214 if (mp == NULL) { 2214 if (mp == NULL) {
2215 /* illegal pointer combination */ 2215 /* illegal pointer combination */
2216 warning(184); 2216 warning(184);
2217 } else { 2217 } else {
2218 /* illegal pointer combination, op %s */ 2218 /* illegal pointer combination (%s) and (%s), op %s */
2219 warning(124, mp->m_name); 2219 warning(124,
 2220 type_name(ltp), type_name(rtp), mp->m_name);
2220 } 2221 }
2221 } 2222 }
2222} 2223}
2223 2224
2224/* 2225/*
2225 * Make sure type (*tpp)->t_subt has at least the qualifiers 2226 * Make sure type (*tpp)->t_subt has at least the qualifiers
2226 * of tp1->t_subt and tp2->t_subt. 2227 * of tp1->t_subt and tp2->t_subt.
2227 */ 2228 */
2228static void 2229static void
2229merge_qualifiers(type_t **tpp, type_t *tp1, type_t *tp2) 2230merge_qualifiers(type_t **tpp, type_t *tp1, type_t *tp2)
2230{ 2231{
2231 2232
2232 lint_assert((*tpp)->t_tspec == PTR); 2233 lint_assert((*tpp)->t_tspec == PTR);