| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: tree.c,v 1.637 2024/04/27 12:46:37 rillig Exp $ */ | | 1 | /* $NetBSD: tree.c,v 1.638 2024/05/01 05:49:33 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.637 2024/04/27 12:46:37 rillig Exp $"); | | 40 | __RCSID("$NetBSD: tree.c,v 1.638 2024/05/01 05:49:33 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 { |
| @@ -753,32 +753,34 @@ balance(op_t op, tnode_t **lnp, tnode_t | | | @@ -753,32 +753,34 @@ balance(op_t op, tnode_t **lnp, tnode_t |
753 | tspec_t rt = (*rnp)->tn_type->t_tspec; | | 753 | tspec_t rt = (*rnp)->tn_type->t_tspec; |
754 | if (!is_arithmetic(lt) || !is_arithmetic(rt)) | | 754 | if (!is_arithmetic(lt) || !is_arithmetic(rt)) |
755 | return; | | 755 | return; |
756 | | | 756 | |
757 | tspec_t t = allow_c90 | | 757 | tspec_t t = allow_c90 |
758 | ? usual_arithmetic_conversion_c90(lt, rt) | | 758 | ? usual_arithmetic_conversion_c90(lt, rt) |
759 | : usual_arithmetic_conversion_trad(lt, rt); | | 759 | : usual_arithmetic_conversion_trad(lt, rt); |
760 | | | 760 | |
761 | if (t != lt) | | 761 | if (t != lt) |
762 | *lnp = apply_usual_arithmetic_conversions(op, *lnp, t); | | 762 | *lnp = apply_usual_arithmetic_conversions(op, *lnp, t); |
763 | if (t != rt) | | 763 | if (t != rt) |
764 | *rnp = apply_usual_arithmetic_conversions(op, *rnp, t); | | 764 | *rnp = apply_usual_arithmetic_conversions(op, *rnp, t); |
765 | | | 765 | |
766 | unsigned lw = (*lnp)->tn_type->t_bit_field_width; | | 766 | if (is_integer(t)) { |
767 | unsigned rw = (*rnp)->tn_type->t_bit_field_width; | | 767 | unsigned lw = width_in_bits((*lnp)->tn_type); |
768 | if (lw < rw) | | 768 | unsigned rw = width_in_bits((*rnp)->tn_type); |
769 | *lnp = convert(NOOP, 0, (*rnp)->tn_type, *lnp); | | 769 | if (lw < rw) |
770 | if (rw < lw) | | 770 | *lnp = convert(NOOP, 0, (*rnp)->tn_type, *lnp); |
771 | *rnp = convert(NOOP, 0, (*lnp)->tn_type, *rnp); | | 771 | if (rw < lw) |
| | | 772 | *rnp = convert(NOOP, 0, (*lnp)->tn_type, *rnp); |
| | | 773 | } |
772 | } | | 774 | } |
773 | | | 775 | |
774 | static tnode_t * | | 776 | static tnode_t * |
775 | build_address(bool sys, tnode_t *tn, bool force) | | 777 | build_address(bool sys, tnode_t *tn, bool force) |
776 | { | | 778 | { |
777 | tspec_t t; | | 779 | tspec_t t; |
778 | | | 780 | |
779 | if (!force && ((t = tn->tn_type->t_tspec) == ARRAY || t == FUNC)) { | | 781 | if (!force && ((t = tn->tn_type->t_tspec) == ARRAY || t == FUNC)) { |
780 | if (!allow_c90) | | 782 | if (!allow_c90) |
781 | /* '&' before array or function: ignored */ | | 783 | /* '&' before array or function: ignored */ |
782 | warning(127); | | 784 | warning(127); |
783 | return tn; | | 785 | return tn; |
784 | } | | 786 | } |