| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: tree.c,v 1.636 2024/04/27 10:08:54 rillig Exp $ */ | | 1 | /* $NetBSD: tree.c,v 1.637 2024/04/27 12:46:37 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) | | 39 | #if defined(__RCSID) |
40 | __RCSID("$NetBSD: tree.c,v 1.636 2024/04/27 10:08:54 rillig Exp $"); | | 40 | __RCSID("$NetBSD: tree.c,v 1.637 2024/04/27 12:46:37 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 | | | 51 | |
52 | | | 52 | |
53 | typedef struct integer_constraints { | | 53 | typedef struct integer_constraints { |
| @@ -1424,27 +1424,28 @@ build_assignment(op_t op, bool sys, tnod | | | @@ -1424,27 +1424,28 @@ build_assignment(op_t op, bool sys, tnod |
1424 | && portable_rank_cmp(lt, rt) < 0) | | 1424 | && portable_rank_cmp(lt, rt) < 0) |
1425 | /* semantics of '%s' change in C90; ... */ | | 1425 | /* semantics of '%s' change in C90; ... */ |
1426 | warning(118, "<<="); | | 1426 | warning(118, "<<="); |
1427 | | | 1427 | |
1428 | if (op != SHLASS && op != SHRASS | | 1428 | if (op != SHLASS && op != SHRASS |
1429 | && (op == ASSIGN || lt != PTR) | | 1429 | && (op == ASSIGN || lt != PTR) |
1430 | && (lt != rt || (ln->tn_type->t_bitfield && rn->tn_op == CON))) { | | 1430 | && (lt != rt || (ln->tn_type->t_bitfield && rn->tn_op == CON))) { |
1431 | rn = convert(op, 0, ln->tn_type, rn); | | 1431 | rn = convert(op, 0, ln->tn_type, rn); |
1432 | rt = lt; | | 1432 | rt = lt; |
1433 | } | | 1433 | } |
1434 | | | 1434 | |
1435 | if (is_query_enabled[20] | | 1435 | if (is_query_enabled[20] |
1436 | && lt == PTR && ln->tn_type->t_subt->t_tspec != VOID | | 1436 | && lt == PTR && ln->tn_type->t_subt->t_tspec != VOID |
1437 | && rt == PTR && rn->tn_type->t_subt->t_tspec == VOID) | | 1437 | && rt == PTR && rn->tn_type->t_subt->t_tspec == VOID |
| | | 1438 | && !is_null_pointer(rn)) |
1438 | /* implicit narrowing conversion from void ... */ | | 1439 | /* implicit narrowing conversion from void ... */ |
1439 | query_message(20, type_name(ln->tn_type)); | | 1440 | query_message(20, type_name(ln->tn_type)); |
1440 | | | 1441 | |
1441 | if (any_query_enabled && rn->tn_op == CVT && rn->tn_cast && | | 1442 | if (any_query_enabled && rn->tn_op == CVT && rn->tn_cast && |
1442 | types_compatible(ln->tn_type, rn->tn_type, false, false, NULL) && | | 1443 | types_compatible(ln->tn_type, rn->tn_type, false, false, NULL) && |
1443 | is_cast_redundant(rn)) { | | 1444 | is_cast_redundant(rn)) { |
1444 | /* redundant cast from '%s' to '%s' before assignment */ | | 1445 | /* redundant cast from '%s' to '%s' before assignment */ |
1445 | query_message(7, type_name(rn->u.ops.left->tn_type), | | 1446 | query_message(7, type_name(rn->u.ops.left->tn_type), |
1446 | type_name(rn->tn_type)); | | 1447 | type_name(rn->tn_type)); |
1447 | } | | 1448 | } |
1448 | | | 1449 | |
1449 | return build_op(op, sys, ln->tn_type, ln, rn); | | 1450 | return build_op(op, sys, ln->tn_type, ln, rn); |
1450 | } | | 1451 | } |