| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: tree.c,v 1.254 2021/03/30 15:18:19 rillig Exp $ */ | | 1 | /* $NetBSD: tree.c,v 1.255 2021/04/01 15:06:49 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.254 2021/03/30 15:18:19 rillig Exp $"); | | 40 | __RCSID("$NetBSD: tree.c,v 1.255 2021/04/01 15:06:49 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 | | | 52 | |
53 | static tnode_t *new_integer_constant_node(tspec_t, int64_t); | | 53 | static tnode_t *new_integer_constant_node(tspec_t, int64_t); |
| @@ -2223,30 +2223,26 @@ check_pointer_integer_conversion(op_t op | | | @@ -2223,30 +2223,26 @@ check_pointer_integer_conversion(op_t op |
2223 | } | | 2223 | } |
2224 | | | 2224 | |
2225 | static bool | | 2225 | static bool |
2226 | should_warn_about_pointer_cast(const type_t *tp, tspec_t nst, | | 2226 | should_warn_about_pointer_cast(const type_t *tp, tspec_t nst, |
2227 | const tnode_t *tn, tspec_t ost) | | 2227 | const tnode_t *tn, tspec_t ost) |
2228 | { | | 2228 | { |
2229 | if (nst == STRUCT || nst == UNION) | | 2229 | if (nst == STRUCT || nst == UNION) |
2230 | if (tp->t_subt->t_str != tn->tn_type->t_subt->t_str) | | 2230 | if (tp->t_subt->t_str != tn->tn_type->t_subt->t_str) |
2231 | return true; | | 2231 | return true; |
2232 | | | 2232 | |
2233 | if (nst == CHAR || nst == UCHAR) | | 2233 | if (nst == CHAR || nst == UCHAR) |
2234 | return false; /* for the sake of traditional C code */ | | 2234 | return false; /* for the sake of traditional C code */ |
2235 | | | 2235 | |
2236 | /* | | | |
2237 | * XXX: Why should it be ok to cast between arbitrary structs that | | | |
2238 | * just happen to be of the same size? | | | |
2239 | */ | | | |
2240 | return portable_size_in_bits(nst) != portable_size_in_bits(ost); | | 2236 | return portable_size_in_bits(nst) != portable_size_in_bits(ost); |
2241 | } | | 2237 | } |
2242 | | | 2238 | |
2243 | /* | | 2239 | /* |
2244 | * Warn about questionable pointer conversions. | | 2240 | * Warn about questionable pointer conversions. |
2245 | */ | | 2241 | */ |
2246 | static void | | 2242 | static void |
2247 | check_pointer_conversion(op_t op, tnode_t *tn, type_t *tp) | | 2243 | check_pointer_conversion(op_t op, tnode_t *tn, type_t *tp) |
2248 | { | | 2244 | { |
2249 | tspec_t nst, ost; | | 2245 | tspec_t nst, ost; |
2250 | const char *nts, *ots; | | 2246 | const char *nts, *ots; |
2251 | | | 2247 | |
2252 | /* | | 2248 | /* |