lint: rename type.t_isfield to t_bitfielddiff -r1.107 -r1.108 src/usr.bin/xlint/lint1/decl.c
(rillig)
--- src/usr.bin/xlint/lint1/decl.c 2021/01/03 18:48:37 1.107
+++ src/usr.bin/xlint/lint1/decl.c 2021/01/03 19:10:47 1.108
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: decl.c,v 1.107 2021/01/03 18:48:37 rillig Exp $ */ | 1 | /* $NetBSD: decl.c,v 1.108 2021/01/03 19:10:47 rillig Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. | 4 | * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. | |
5 | * Copyright (c) 1994, 1995 Jochen Pohl | 5 | * Copyright (c) 1994, 1995 Jochen Pohl | |
6 | * All Rights Reserved. | 6 | * All Rights Reserved. | |
7 | * | 7 | * | |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without | |
9 | * modification, are permitted provided that the following conditions | 9 | * modification, are permitted provided that the following conditions | |
10 | * are met: | 10 | * are met: | |
11 | * 1. Redistributions of source code must retain the above copyright | 11 | * 1. Redistributions of source code must retain the above copyright | |
12 | * notice, this list of conditions and the following disclaimer. | 12 | * notice, this list of conditions and the following disclaimer. | |
13 | * 2. Redistributions in binary form must reproduce the above copyright | 13 | * 2. Redistributions in binary form must reproduce the above copyright | |
14 | * notice, this list of conditions and the following disclaimer in the | 14 | * notice, this list of conditions and the following disclaimer in the | |
@@ -28,27 +28,27 @@ | @@ -28,27 +28,27 @@ | |||
28 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 28 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
32 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 32 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
33 | */ | 33 | */ | |
34 | 34 | |||
35 | #if HAVE_NBTOOL_CONFIG_H | 35 | #if HAVE_NBTOOL_CONFIG_H | |
36 | #include "nbtool_config.h" | 36 | #include "nbtool_config.h" | |
37 | #endif | 37 | #endif | |
38 | 38 | |||
39 | #include <sys/cdefs.h> | 39 | #include <sys/cdefs.h> | |
40 | #if defined(__RCSID) && !defined(lint) | 40 | #if defined(__RCSID) && !defined(lint) | |
41 | __RCSID("$NetBSD: decl.c,v 1.107 2021/01/03 18:48:37 rillig Exp $"); | 41 | __RCSID("$NetBSD: decl.c,v 1.108 2021/01/03 19:10:47 rillig Exp $"); | |
42 | #endif | 42 | #endif | |
43 | 43 | |||
44 | #include <sys/param.h> | 44 | #include <sys/param.h> | |
45 | #include <limits.h> | 45 | #include <limits.h> | |
46 | #include <stdlib.h> | 46 | #include <stdlib.h> | |
47 | #include <string.h> | 47 | #include <string.h> | |
48 | 48 | |||
49 | #include "lint1.h" | 49 | #include "lint1.h" | |
50 | 50 | |||
51 | const char *unnamed = "<unnamed>"; | 51 | const char *unnamed = "<unnamed>"; | |
52 | 52 | |||
53 | /* shared type structures for arithmtic types and void */ | 53 | /* shared type structures for arithmtic types and void */ | |
54 | static type_t *typetab; | 54 | static type_t *typetab; | |
@@ -484,46 +484,46 @@ settdsym(type_t *tp, sym_t *sym) | @@ -484,46 +484,46 @@ settdsym(type_t *tp, sym_t *sym) | |||
484 | if ((t = tp->t_tspec) == STRUCT || t == UNION) { | 484 | if ((t = tp->t_tspec) == STRUCT || t == UNION) { | |
485 | if (tp->t_str->stdef == NULL) | 485 | if (tp->t_str->stdef == NULL) | |
486 | tp->t_str->stdef = sym; | 486 | tp->t_str->stdef = sym; | |
487 | } else if (t == ENUM) { | 487 | } else if (t == ENUM) { | |
488 | if (tp->t_enum->etdef == NULL) | 488 | if (tp->t_enum->etdef == NULL) | |
489 | tp->t_enum->etdef = sym; | 489 | tp->t_enum->etdef = sym; | |
490 | } | 490 | } | |
491 | } | 491 | } | |
492 | 492 | |||
493 | static size_t | 493 | static size_t | |
494 | bitfieldsize(sym_t **mem) | 494 | bitfieldsize(sym_t **mem) | |
495 | { | 495 | { | |
496 | size_t len = (*mem)->s_type->t_flen; | 496 | size_t len = (*mem)->s_type->t_flen; | |
497 | while (*mem && (*mem)->s_type->t_isfield) { | 497 | while (*mem && (*mem)->s_type->t_bitfield) { | |
498 | len += (*mem)->s_type->t_flen; | 498 | len += (*mem)->s_type->t_flen; | |
499 | *mem = (*mem)->s_next; | 499 | *mem = (*mem)->s_next; | |
500 | } | 500 | } | |
501 | return ((len + INT_SIZE - 1) / INT_SIZE) * INT_SIZE; | 501 | return ((len + INT_SIZE - 1) / INT_SIZE) * INT_SIZE; | |
502 | } | 502 | } | |
503 | 503 | |||
504 | static void | 504 | static void | |
505 | setpackedsize(type_t *tp) | 505 | setpackedsize(type_t *tp) | |
506 | { | 506 | { | |
507 | str_t *sp; | 507 | str_t *sp; | |
508 | sym_t *mem; | 508 | sym_t *mem; | |
509 | 509 | |||
510 | switch (tp->t_tspec) { | 510 | switch (tp->t_tspec) { | |
511 | case STRUCT: | 511 | case STRUCT: | |
512 | case UNION: | 512 | case UNION: | |
513 | sp = tp->t_str; | 513 | sp = tp->t_str; | |
514 | sp->size = 0; | 514 | sp->size = 0; | |
515 | for (mem = sp->memb; mem != NULL; mem = mem->s_next) { | 515 | for (mem = sp->memb; mem != NULL; mem = mem->s_next) { | |
516 | if (mem->s_type->t_isfield) { | 516 | if (mem->s_type->t_bitfield) { | |
517 | sp->size += bitfieldsize(&mem); | 517 | sp->size += bitfieldsize(&mem); | |
518 | if (mem == NULL) | 518 | if (mem == NULL) | |
519 | break; | 519 | break; | |
520 | } | 520 | } | |
521 | size_t x = (size_t)tsize(mem->s_type); | 521 | size_t x = (size_t)tsize(mem->s_type); | |
522 | if (tp->t_tspec == STRUCT) | 522 | if (tp->t_tspec == STRUCT) | |
523 | sp->size += x; | 523 | sp->size += x; | |
524 | else if (x > sp->size) | 524 | else if (x > sp->size) | |
525 | sp->size = x; | 525 | sp->size = x; | |
526 | } | 526 | } | |
527 | break; | 527 | break; | |
528 | default: | 528 | default: | |
529 | /* %s attribute ignored for %s */ | 529 | /* %s attribute ignored for %s */ | |
@@ -1138,27 +1138,27 @@ declarator_1_struct_union(sym_t *dsym) | @@ -1138,27 +1138,27 @@ declarator_1_struct_union(sym_t *dsym) | |||
1138 | } | 1138 | } | |
1139 | if ((len = tp->t_flen) < 0 || len > (ssize_t)size(t)) { | 1139 | if ((len = tp->t_flen) < 0 || len > (ssize_t)size(t)) { | |
1140 | /* illegal bit-field size: %d */ | 1140 | /* illegal bit-field size: %d */ | |
1141 | error(36, len); | 1141 | error(36, len); | |
1142 | tp->t_flen = size(t); | 1142 | tp->t_flen = size(t); | |
1143 | } else if (len == 0 && dsym->s_name != unnamed) { | 1143 | } else if (len == 0 && dsym->s_name != unnamed) { | |
1144 | /* zero size bit-field */ | 1144 | /* zero size bit-field */ | |
1145 | error(37); | 1145 | error(37); | |
1146 | tp->t_flen = size(t); | 1146 | tp->t_flen = size(t); | |
1147 | } | 1147 | } | |
1148 | if (dsym->s_scl == MOU) { | 1148 | if (dsym->s_scl == MOU) { | |
1149 | /* illegal use of bit-field */ | 1149 | /* illegal use of bit-field */ | |
1150 | error(41); | 1150 | error(41); | |
1151 | dsym->s_type->t_isfield = 0; | 1151 | dsym->s_type->t_bitfield = false; | |
1152 | dsym->s_bitfield = 0; | 1152 | dsym->s_bitfield = 0; | |
1153 | } | 1153 | } | |
1154 | } else if (t == FUNC) { | 1154 | } else if (t == FUNC) { | |
1155 | /* function illegal in structure or union */ | 1155 | /* function illegal in structure or union */ | |
1156 | error(38); | 1156 | error(38); | |
1157 | dsym->s_type = tp = incref(tp, t = PTR); | 1157 | dsym->s_type = tp = incref(tp, t = PTR); | |
1158 | } | 1158 | } | |
1159 | 1159 | |||
1160 | /* | 1160 | /* | |
1161 | * bit-fields of length 0 are not warned about because length() | 1161 | * bit-fields of length 0 are not warned about because length() | |
1162 | * does not return the length of the bit-field but the length | 1162 | * does not return the length of the bit-field but the length | |
1163 | * of the type the bit-field is packed in (it's ok) | 1163 | * of the type the bit-field is packed in (it's ok) | |
1164 | */ | 1164 | */ | |
@@ -1228,27 +1228,27 @@ align(int al, int len) | @@ -1228,27 +1228,27 @@ align(int al, int len) | |||
1228 | sym_t * | 1228 | sym_t * | |
1229 | bitfield(sym_t *dsym, int len) | 1229 | bitfield(sym_t *dsym, int len) | |
1230 | { | 1230 | { | |
1231 | 1231 | |||
1232 | if (dsym == NULL) { | 1232 | if (dsym == NULL) { | |
1233 | dsym = getblk(sizeof (sym_t)); | 1233 | dsym = getblk(sizeof (sym_t)); | |
1234 | dsym->s_name = unnamed; | 1234 | dsym->s_name = unnamed; | |
1235 | dsym->s_kind = FMEMBER; | 1235 | dsym->s_kind = FMEMBER; | |
1236 | dsym->s_scl = MOS; | 1236 | dsym->s_scl = MOS; | |
1237 | dsym->s_type = gettyp(UINT); | 1237 | dsym->s_type = gettyp(UINT); | |
1238 | dsym->s_blklev = -1; | 1238 | dsym->s_blklev = -1; | |
1239 | } | 1239 | } | |
1240 | dsym->s_type = duptyp(dsym->s_type); | 1240 | dsym->s_type = duptyp(dsym->s_type); | |
1241 | dsym->s_type->t_isfield = 1; | 1241 | dsym->s_type->t_bitfield = true; | |
1242 | dsym->s_type->t_flen = len; | 1242 | dsym->s_type->t_flen = len; | |
1243 | dsym->s_bitfield = 1; | 1243 | dsym->s_bitfield = 1; | |
1244 | return dsym; | 1244 | return dsym; | |
1245 | } | 1245 | } | |
1246 | 1246 | |||
1247 | /* | 1247 | /* | |
1248 | * Collect information about a sequence of asterisks and qualifiers in a | 1248 | * Collect information about a sequence of asterisks and qualifiers in a | |
1249 | * list of type pqinf_t. | 1249 | * list of type pqinf_t. | |
1250 | * Qualifiers always refer to the left asterisk. | 1250 | * Qualifiers always refer to the left asterisk. | |
1251 | * The rightmost asterisk will be at the top of the list. | 1251 | * The rightmost asterisk will be at the top of the list. | |
1252 | */ | 1252 | */ | |
1253 | pqinf_t * | 1253 | pqinf_t * | |
1254 | merge_pointers_and_qualifiers(pqinf_t *p1, pqinf_t *p2) | 1254 | merge_pointers_and_qualifiers(pqinf_t *p1, pqinf_t *p2) | |
@@ -1777,27 +1777,27 @@ complete_tag_struct_or_union(type_t *tp, | @@ -1777,27 +1777,27 @@ complete_tag_struct_or_union(type_t *tp, | |||
1777 | else | 1777 | else | |
1778 | sp->size = dcs->d_offset; | 1778 | sp->size = dcs->d_offset; | |
1779 | 1779 | |||
1780 | if (sp->size == 0) { | 1780 | if (sp->size == 0) { | |
1781 | /* zero sized %s is a C9X feature */ | 1781 | /* zero sized %s is a C9X feature */ | |
1782 | c99ism(47, ttab[t].tt_name); | 1782 | c99ism(47, ttab[t].tt_name); | |
1783 | } | 1783 | } | |
1784 | 1784 | |||
1785 | n = 0; | 1785 | n = 0; | |
1786 | for (mem = fmem; mem != NULL; mem = mem->s_next) { | 1786 | for (mem = fmem; mem != NULL; mem = mem->s_next) { | |
1787 | /* bind anonymous members to the structure */ | 1787 | /* bind anonymous members to the structure */ | |
1788 | if (mem->s_styp == NULL) { | 1788 | if (mem->s_styp == NULL) { | |
1789 | mem->s_styp = sp; | 1789 | mem->s_styp = sp; | |
1790 | if (mem->s_type->t_isfield) { | 1790 | if (mem->s_type->t_bitfield) { | |
1791 | sp->size += bitfieldsize(&mem); | 1791 | sp->size += bitfieldsize(&mem); | |
1792 | if (mem == NULL) | 1792 | if (mem == NULL) | |
1793 | break; | 1793 | break; | |
1794 | } | 1794 | } | |
1795 | sp->size += tsize(mem->s_type); | 1795 | sp->size += tsize(mem->s_type); | |
1796 | } | 1796 | } | |
1797 | if (mem->s_name != unnamed) | 1797 | if (mem->s_name != unnamed) | |
1798 | n++; | 1798 | n++; | |
1799 | } | 1799 | } | |
1800 | 1800 | |||
1801 | if (n == 0 && sp->size != 0) { | 1801 | if (n == 0 && sp->size != 0) { | |
1802 | /* %s has no named members */ | 1802 | /* %s has no named members */ | |
1803 | warning(65, t == STRUCT ? "structure" : "union"); | 1803 | warning(65, t == STRUCT ? "structure" : "union"); |
--- src/usr.bin/xlint/lint1/init.c 2021/01/03 17:42:45 1.58
+++ src/usr.bin/xlint/lint1/init.c 2021/01/03 19:10:47 1.59
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: init.c,v 1.58 2021/01/03 17:42:45 rillig Exp $ */ | 1 | /* $NetBSD: init.c,v 1.59 2021/01/03 19:10:47 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: init.c,v 1.58 2021/01/03 17:42:45 rillig Exp $"); | 40 | __RCSID("$NetBSD: init.c,v 1.59 2021/01/03 19:10:47 rillig Exp $"); | |
41 | #endif | 41 | #endif | |
42 | 42 | |||
43 | #include <stdlib.h> | 43 | #include <stdlib.h> | |
44 | #include <string.h> | 44 | #include <string.h> | |
45 | 45 | |||
46 | #include "lint1.h" | 46 | #include "lint1.h" | |
47 | 47 | |||
48 | 48 | |||
49 | /* | 49 | /* | |
50 | * Type of stack which is used for initialisation of aggregate types. | 50 | * Type of stack which is used for initialisation of aggregate types. | |
51 | * | 51 | * | |
52 | * XXX: Since C99, a stack is an inappropriate data structure for modelling | 52 | * XXX: Since C99, a stack is an inappropriate data structure for modelling | |
53 | * an initialization, since the designators don't have to be listed in a | 53 | * an initialization, since the designators don't have to be listed in a | |
@@ -623,37 +623,37 @@ mkinit(tnode_t *tn) | @@ -623,37 +623,37 @@ mkinit(tnode_t *tn) | |||
623 | lint_assert(tspec_is_scalar(lt)); | 623 | lint_assert(tspec_is_scalar(lt)); | |
624 | 624 | |||
625 | if (!typeok(INIT, 0, ln, tn)) | 625 | if (!typeok(INIT, 0, ln, tn)) | |
626 | return; | 626 | return; | |
627 | 627 | |||
628 | /* | 628 | /* | |
629 | * Store the tree memory. This is necessary because otherwise | 629 | * Store the tree memory. This is necessary because otherwise | |
630 | * expr() would free it. | 630 | * expr() would free it. | |
631 | */ | 631 | */ | |
632 | tmem = tsave(); | 632 | tmem = tsave(); | |
633 | expr(tn, 1, 0, 1); | 633 | expr(tn, 1, 0, 1); | |
634 | trestor(tmem); | 634 | trestor(tmem); | |
635 | 635 | |||
636 | if (tspec_is_int(lt) && ln->tn_type->t_isfield && !tspec_is_int(rt)) { | 636 | if (tspec_is_int(lt) && ln->tn_type->t_bitfield && !tspec_is_int(rt)) { | |
637 | /* | 637 | /* | |
638 | * Bit-fields can be initialized in trad. C only by integer | 638 | * Bit-fields can be initialized in trad. C only by integer | |
639 | * constants. | 639 | * constants. | |
640 | */ | 640 | */ | |
641 | if (tflag) | 641 | if (tflag) | |
642 | /* bit-field initialisation is illegal in trad. C */ | 642 | /* bit-field initialisation is illegal in trad. C */ | |
643 | warning(186); | 643 | warning(186); | |
644 | } | 644 | } | |
645 | 645 | |||
646 | if (lt != rt || (initstk->i_type->t_isfield && tn->tn_op == CON)) | 646 | if (lt != rt || (initstk->i_type->t_bitfield && tn->tn_op == CON)) | |
647 | tn = convert(INIT, 0, initstk->i_type, tn); | 647 | tn = convert(INIT, 0, initstk->i_type, tn); | |
648 | 648 | |||
649 | if (tn != NULL && tn->tn_op != CON) { | 649 | if (tn != NULL && tn->tn_op != CON) { | |
650 | sym = NULL; | 650 | sym = NULL; | |
651 | offs = 0; | 651 | offs = 0; | |
652 | if (conaddr(tn, &sym, &offs) == -1) { | 652 | if (conaddr(tn, &sym, &offs) == -1) { | |
653 | if (sc == AUTO || sc == REG) { | 653 | if (sc == AUTO || sc == REG) { | |
654 | /* non-constant initializer */ | 654 | /* non-constant initializer */ | |
655 | c99ism(177); | 655 | c99ism(177); | |
656 | } else { | 656 | } else { | |
657 | /* non-constant initializer */ | 657 | /* non-constant initializer */ | |
658 | error(177); | 658 | error(177); | |
659 | } | 659 | } |
--- src/usr.bin/xlint/lint1/lint1.h 2021/01/03 18:48:37 1.49
+++ src/usr.bin/xlint/lint1/lint1.h 2021/01/03 19:10:47 1.50
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: lint1.h,v 1.49 2021/01/03 18:48:37 rillig Exp $ */ | 1 | /* $NetBSD: lint1.h,v 1.50 2021/01/03 19:10:47 rillig Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. | 4 | * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. | |
5 | * Copyright (c) 1994, 1995 Jochen Pohl | 5 | * Copyright (c) 1994, 1995 Jochen Pohl | |
6 | * All Rights Reserved. | 6 | * All Rights Reserved. | |
7 | * | 7 | * | |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without | |
9 | * modification, are permitted provided that the following conditions | 9 | * modification, are permitted provided that the following conditions | |
10 | * are met: | 10 | * are met: | |
11 | * 1. Redistributions of source code must retain the above copyright | 11 | * 1. Redistributions of source code must retain the above copyright | |
12 | * notice, this list of conditions and the following disclaimer. | 12 | * notice, this list of conditions and the following disclaimer. | |
13 | * 2. Redistributions in binary form must reproduce the above copyright | 13 | * 2. Redistributions in binary form must reproduce the above copyright | |
14 | * notice, this list of conditions and the following disclaimer in the | 14 | * notice, this list of conditions and the following disclaimer in the | |
@@ -146,27 +146,27 @@ typedef struct { | @@ -146,27 +146,27 @@ typedef struct { | |||
146 | 146 | |||
147 | /* | 147 | /* | |
148 | * Types are represented by concatenation of structures of type type_t | 148 | * Types are represented by concatenation of structures of type type_t | |
149 | * via t_subt. | 149 | * via t_subt. | |
150 | */ | 150 | */ | |
151 | struct type { | 151 | struct type { | |
152 | tspec_t t_tspec; /* type specifier */ | 152 | tspec_t t_tspec; /* type specifier */ | |
153 | bool t_aincompl : 1; /* incomplete array type */ | 153 | bool t_aincompl : 1; /* incomplete array type */ | |
154 | bool t_const : 1; /* const modifier */ | 154 | bool t_const : 1; /* const modifier */ | |
155 | bool t_volatile : 1; /* volatile modifier */ | 155 | bool t_volatile : 1; /* volatile modifier */ | |
156 | bool t_proto : 1; /* function prototype (t_args valid) */ | 156 | bool t_proto : 1; /* function prototype (t_args valid) */ | |
157 | bool t_vararg : 1; /* prototype with ... */ | 157 | bool t_vararg : 1; /* prototype with ... */ | |
158 | bool t_typedef : 1; /* type defined with typedef */ | 158 | bool t_typedef : 1; /* type defined with typedef */ | |
159 | bool t_isfield : 1; /* type is bitfield */ | 159 | bool t_bitfield : 1; | |
160 | bool t_isenum : 1; /* type is (or was) enum (t_enum valid) */ | 160 | bool t_isenum : 1; /* type is (or was) enum (t_enum valid) */ | |
161 | bool t_ispacked : 1; /* type is packed */ | 161 | bool t_ispacked : 1; /* type is packed */ | |
162 | union { | 162 | union { | |
163 | int _t_dim; /* dimension */ | 163 | int _t_dim; /* dimension */ | |
164 | str_t *_t_str; /* struct/union tag */ | 164 | str_t *_t_str; /* struct/union tag */ | |
165 | tenum_t *_t_enum; /* enum tag */ | 165 | tenum_t *_t_enum; /* enum tag */ | |
166 | struct sym *_t_args; /* arguments (if t_proto) */ | 166 | struct sym *_t_args; /* arguments (if t_proto) */ | |
167 | } t_u; | 167 | } t_u; | |
168 | struct { | 168 | struct { | |
169 | u_int _t_flen : 8; /* length of bit-field */ | 169 | u_int _t_flen : 8; /* length of bit-field */ | |
170 | u_int _t_foffs : 24; /* offset of bit-field */ | 170 | u_int _t_foffs : 24; /* offset of bit-field */ | |
171 | } t_b; | 171 | } t_b; | |
172 | struct type *t_subt; /* element type (arrays), return value | 172 | struct type *t_subt; /* element type (arrays), return value |
--- src/usr.bin/xlint/lint1/tree.c 2021/01/03 18:35:51 1.119
+++ src/usr.bin/xlint/lint1/tree.c 2021/01/03 19:10:47 1.120
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: tree.c,v 1.119 2021/01/03 18:35:51 rillig Exp $ */ | 1 | /* $NetBSD: tree.c,v 1.120 2021/01/03 19:10:47 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.119 2021/01/03 18:35:51 rillig Exp $"); | 40 | __RCSID("$NetBSD: tree.c,v 1.120 2021/01/03 19:10:47 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_int_const_node(tspec_t, int64_t); | 53 | static tnode_t *new_int_const_node(tspec_t, int64_t); | |
@@ -749,27 +749,27 @@ typeok(op_t op, int arg, tnode_t *ln, tn | @@ -749,27 +749,27 @@ typeok(op_t op, int arg, tnode_t *ln, tn | |||
749 | olt = tn->tn_type->t_tspec; | 749 | olt = tn->tn_type->t_tspec; | |
750 | for (tn=rn; tn->tn_op==CVT && !tn->tn_cast; tn=tn->tn_left) | 750 | for (tn=rn; tn->tn_op==CVT && !tn->tn_cast; tn=tn->tn_left) | |
751 | continue; | 751 | continue; | |
752 | ort = tn->tn_type->t_tspec; | 752 | ort = tn->tn_type->t_tspec; | |
753 | } | 753 | } | |
754 | 754 | |||
755 | switch (op) { | 755 | switch (op) { | |
756 | case POINT: | 756 | case POINT: | |
757 | /* | 757 | /* | |
758 | * Most errors required by ANSI C are reported in | 758 | * Most errors required by ANSI C are reported in | |
759 | * struct_or_union_member(). | 759 | * struct_or_union_member(). | |
760 | * Here we only must check for totally wrong things. | 760 | * Here we only must check for totally wrong things. | |
761 | */ | 761 | */ | |
762 | if (lt == FUNC || lt == VOID || ltp->t_isfield || | 762 | if (lt == FUNC || lt == VOID || ltp->t_bitfield || | |
763 | ((lt != STRUCT && lt != UNION) && !ln->tn_lvalue)) { | 763 | ((lt != STRUCT && lt != UNION) && !ln->tn_lvalue)) { | |
764 | /* Without tflag we got already an error */ | 764 | /* Without tflag we got already an error */ | |
765 | if (tflag) | 765 | if (tflag) | |
766 | /* unacceptable operand of '%s' */ | 766 | /* unacceptable operand of '%s' */ | |
767 | error(111, mp->m_name); | 767 | error(111, mp->m_name); | |
768 | return 0; | 768 | return 0; | |
769 | } | 769 | } | |
770 | /* Now we have an object we can create a pointer to */ | 770 | /* Now we have an object we can create a pointer to */ | |
771 | break; | 771 | break; | |
772 | case ARROW: | 772 | case ARROW: | |
773 | if (lt != PTR && !(tflag && tspec_is_int(lt))) { | 773 | if (lt != PTR && !(tflag && tspec_is_int(lt))) { | |
774 | /* Without tflag we got already an error */ | 774 | /* Without tflag we got already an error */ | |
775 | if (tflag) | 775 | if (tflag) | |
@@ -805,27 +805,27 @@ typeok(op_t op, int arg, tnode_t *ln, tn | @@ -805,27 +805,27 @@ typeok(op_t op, int arg, tnode_t *ln, tn | |||
805 | /* ok, a warning comes later (in build_ampersand()) */ | 805 | /* ok, a warning comes later (in build_ampersand()) */ | |
806 | } else if (!ln->tn_lvalue) { | 806 | } else if (!ln->tn_lvalue) { | |
807 | if (ln->tn_op == CVT && ln->tn_cast && | 807 | if (ln->tn_op == CVT && ln->tn_cast && | |
808 | ln->tn_left->tn_op == LOAD) { | 808 | ln->tn_left->tn_op == LOAD) { | |
809 | if (ln->tn_type->t_tspec == PTR) | 809 | if (ln->tn_type->t_tspec == PTR) | |
810 | break; | 810 | break; | |
811 | /* a cast does not yield an lvalue */ | 811 | /* a cast does not yield an lvalue */ | |
812 | error(163); | 812 | error(163); | |
813 | } | 813 | } | |
814 | /* %soperand of '%s' must be lvalue */ | 814 | /* %soperand of '%s' must be lvalue */ | |
815 | error(114, "", mp->m_name); | 815 | error(114, "", mp->m_name); | |
816 | return 0; | 816 | return 0; | |
817 | } else if (tspec_is_scalar(lt)) { | 817 | } else if (tspec_is_scalar(lt)) { | |
818 | if (ltp->t_isfield) { | 818 | if (ltp->t_bitfield) { | |
819 | /* cannot take address of bit-field */ | 819 | /* cannot take address of bit-field */ | |
820 | error(112); | 820 | error(112); | |
821 | return 0; | 821 | return 0; | |
822 | } | 822 | } | |
823 | } else if (lt != STRUCT && lt != UNION) { | 823 | } else if (lt != STRUCT && lt != UNION) { | |
824 | /* unacceptable operand of '%s' */ | 824 | /* unacceptable operand of '%s' */ | |
825 | error(111, mp->m_name); | 825 | error(111, mp->m_name); | |
826 | return 0; | 826 | return 0; | |
827 | } | 827 | } | |
828 | if (ln->tn_op == NAME && ln->tn_sym->s_reg) { | 828 | if (ln->tn_op == NAME && ln->tn_sym->s_reg) { | |
829 | /* cannot take address of register %s */ | 829 | /* cannot take address of register %s */ | |
830 | error(113, ln->tn_sym->s_name); | 830 | error(113, ln->tn_sym->s_name); | |
831 | return 0; | 831 | return 0; | |
@@ -1520,27 +1520,27 @@ promote(op_t op, int farg, tnode_t *tn) | @@ -1520,27 +1520,27 @@ promote(op_t op, int farg, tnode_t *tn) | |||
1520 | u_int len; | 1520 | u_int len; | |
1521 | 1521 | |||
1522 | t = tn->tn_type->t_tspec; | 1522 | t = tn->tn_type->t_tspec; | |
1523 | 1523 | |||
1524 | if (!tspec_is_arith(t)) | 1524 | if (!tspec_is_arith(t)) | |
1525 | return tn; | 1525 | return tn; | |
1526 | 1526 | |||
1527 | if (!tflag) { | 1527 | if (!tflag) { | |
1528 | /* | 1528 | /* | |
1529 | * ANSI C requires that the result is always of type INT | 1529 | * ANSI C requires that the result is always of type INT | |
1530 | * if INT can represent all possible values of the previous | 1530 | * if INT can represent all possible values of the previous | |
1531 | * type. | 1531 | * type. | |
1532 | */ | 1532 | */ | |
1533 | if (tn->tn_type->t_isfield) { | 1533 | if (tn->tn_type->t_bitfield) { | |
1534 | len = tn->tn_type->t_flen; | 1534 | len = tn->tn_type->t_flen; | |
1535 | if (size(INT) > len) { | 1535 | if (size(INT) > len) { | |
1536 | t = INT; | 1536 | t = INT; | |
1537 | } else { | 1537 | } else { | |
1538 | lint_assert(len == size(INT)); | 1538 | lint_assert(len == size(INT)); | |
1539 | if (tspec_is_uint(t)) { | 1539 | if (tspec_is_uint(t)) { | |
1540 | t = UINT; | 1540 | t = UINT; | |
1541 | } else { | 1541 | } else { | |
1542 | t = INT; | 1542 | t = INT; | |
1543 | } | 1543 | } | |
1544 | } | 1544 | } | |
1545 | } else if (t == CHAR || t == UCHAR || t == SCHAR) { | 1545 | } else if (t == CHAR || t == UCHAR || t == SCHAR) { | |
1546 | t = (size(CHAR) < size(INT) || t != UCHAR) ? | 1546 | t = (size(CHAR) < size(INT) || t != UCHAR) ? | |
@@ -2018,34 +2018,34 @@ cvtcon(op_t op, int arg, type_t *tp, val | @@ -2018,34 +2018,34 @@ cvtcon(op_t op, int arg, type_t *tp, val | |||
2018 | warning(157); | 2018 | warning(157); | |
2019 | v->v_ansiu = 0; | 2019 | v->v_ansiu = 0; | |
2020 | } | 2020 | } | |
2021 | 2021 | |||
2022 | switch (nt) { | 2022 | switch (nt) { | |
2023 | case FLOAT: | 2023 | case FLOAT: | |
2024 | case FCOMPLEX: | 2024 | case FCOMPLEX: | |
2025 | case DOUBLE: | 2025 | case DOUBLE: | |
2026 | case DCOMPLEX: | 2026 | case DCOMPLEX: | |
2027 | case LDOUBLE: | 2027 | case LDOUBLE: | |
2028 | case LCOMPLEX: | 2028 | case LCOMPLEX: | |
2029 | break; | 2029 | break; | |
2030 | default: | 2030 | default: | |
2031 | sz = tp->t_isfield ? tp->t_flen : size(nt); | 2031 | sz = tp->t_bitfield ? tp->t_flen : size(nt); | |
2032 | nv->v_quad = xsign(nv->v_quad, nt, sz); | 2032 | nv->v_quad = xsign(nv->v_quad, nt, sz); | |
2033 | break; | 2033 | break; | |
2034 | } | 2034 | } | |
2035 | 2035 | |||
2036 | if (rchk && op != CVT) { | 2036 | if (rchk && op != CVT) { | |
2037 | osz = size(ot); | 2037 | osz = size(ot); | |
2038 | nsz = tp->t_isfield ? tp->t_flen : size(nt); | 2038 | nsz = tp->t_bitfield ? tp->t_flen : size(nt); | |
2039 | xmask = qlmasks[nsz] ^ qlmasks[osz]; | 2039 | xmask = qlmasks[nsz] ^ qlmasks[osz]; | |
2040 | xmsk1 = qlmasks[nsz] ^ qlmasks[osz - 1]; | 2040 | xmsk1 = qlmasks[nsz] ^ qlmasks[osz - 1]; | |
2041 | /* | 2041 | /* | |
2042 | * For bitwise operations we are not interested in the | 2042 | * For bitwise operations we are not interested in the | |
2043 | * value, but in the bits itself. | 2043 | * value, but in the bits itself. | |
2044 | */ | 2044 | */ | |
2045 | if (op == ORASS || op == OR || op == XOR) { | 2045 | if (op == ORASS || op == OR || op == XOR) { | |
2046 | /* | 2046 | /* | |
2047 | * Print a warning if bits which were set are | 2047 | * Print a warning if bits which were set are | |
2048 | * lost due to the conversion. | 2048 | * lost due to the conversion. | |
2049 | * This can happen with operator ORASS only. | 2049 | * This can happen with operator ORASS only. | |
2050 | */ | 2050 | */ | |
2051 | if (nsz < osz && (v->v_quad & xmask) != 0) { | 2051 | if (nsz < osz && (v->v_quad & xmask) != 0) { | |
@@ -2097,55 +2097,55 @@ cvtcon(op_t op, int arg, type_t *tp, val | @@ -2097,55 +2097,55 @@ cvtcon(op_t op, int arg, type_t *tp, val | |||
2097 | * msb of the target for signed types are considered | 2097 | * msb of the target for signed types are considered | |
2098 | * to be significant bits. Loss of significant bits | 2098 | * to be significant bits. Loss of significant bits | |
2099 | * means that at least on of the bits was set in an | 2099 | * means that at least on of the bits was set in an | |
2100 | * unsigned type or that at least one, but not all of | 2100 | * unsigned type or that at least one, but not all of | |
2101 | * the bits was set in an signed type. | 2101 | * the bits was set in an signed type. | |
2102 | * Loss of significant bits means that it is not | 2102 | * Loss of significant bits means that it is not | |
2103 | * possible, also not with necessary casts, to convert | 2103 | * possible, also not with necessary casts, to convert | |
2104 | * back to the original type. A example for a | 2104 | * back to the original type. A example for a | |
2105 | * necessary cast is: | 2105 | * necessary cast is: | |
2106 | * char c; int i; c = 128; | 2106 | * char c; int i; c = 128; | |
2107 | * i = c; ** yields -128 ** | 2107 | * i = c; ** yields -128 ** | |
2108 | * i = (unsigned char)c; ** yields 128 ** | 2108 | * i = (unsigned char)c; ** yields 128 ** | |
2109 | */ | 2109 | */ | |
2110 | if (op == ASSIGN && tp->t_isfield) { | 2110 | if (op == ASSIGN && tp->t_bitfield) { | |
2111 | /* precision lost in bit-field assignment */ | 2111 | /* precision lost in bit-field assignment */ | |
2112 | warning(166); | 2112 | warning(166); | |
2113 | } else if (op == ASSIGN) { | 2113 | } else if (op == ASSIGN) { | |
2114 | /* constant truncated by assignment */ | 2114 | /* constant truncated by assignment */ | |
2115 | warning(165); | 2115 | warning(165); | |
2116 | } else if (op == INIT && tp->t_isfield) { | 2116 | } else if (op == INIT && tp->t_bitfield) { | |
2117 | /* bit-field initializer does not fit */ | 2117 | /* bit-field initializer does not fit */ | |
2118 | warning(180); | 2118 | warning(180); | |
2119 | } else if (op == INIT) { | 2119 | } else if (op == INIT) { | |
2120 | /* initializer does not fit */ | 2120 | /* initializer does not fit */ | |
2121 | warning(178); | 2121 | warning(178); | |
2122 | } else if (op == CASE) { | 2122 | } else if (op == CASE) { | |
2123 | /* case label affected by conversion */ | 2123 | /* case label affected by conversion */ | |
2124 | warning(196); | 2124 | warning(196); | |
2125 | } else if (op == FARG) { | 2125 | } else if (op == FARG) { | |
2126 | /* conv. of '%s' to '%s' is out of range, ... */ | 2126 | /* conv. of '%s' to '%s' is out of range, ... */ | |
2127 | warning(295, | 2127 | warning(295, | |
2128 | type_name(gettyp(ot)), type_name(tp), arg); | 2128 | type_name(gettyp(ot)), type_name(tp), arg); | |
2129 | } else { | 2129 | } else { | |
2130 | /* conversion of '%s' to '%s' is out of range */ | 2130 | /* conversion of '%s' to '%s' is out of range */ | |
2131 | warning(119, | 2131 | warning(119, | |
2132 | type_name(gettyp(ot)), type_name(tp)); | 2132 | type_name(gettyp(ot)), type_name(tp)); | |
2133 | } | 2133 | } | |
2134 | } else if (nv->v_quad != v->v_quad) { | 2134 | } else if (nv->v_quad != v->v_quad) { | |
2135 | if (op == ASSIGN && tp->t_isfield) { | 2135 | if (op == ASSIGN && tp->t_bitfield) { | |
2136 | /* precision lost in bit-field assignment */ | 2136 | /* precision lost in bit-field assignment */ | |
2137 | warning(166); | 2137 | warning(166); | |
2138 | } else if (op == INIT && tp->t_isfield) { | 2138 | } else if (op == INIT && tp->t_bitfield) { | |
2139 | /* bit-field initializer out of range */ | 2139 | /* bit-field initializer out of range */ | |
2140 | warning(11); | 2140 | warning(11); | |
2141 | } else if (op == CASE) { | 2141 | } else if (op == CASE) { | |
2142 | /* case label affected by conversion */ | 2142 | /* case label affected by conversion */ | |
2143 | warning(196); | 2143 | warning(196); | |
2144 | } else if (op == FARG) { | 2144 | } else if (op == FARG) { | |
2145 | /* conv. of '%s' to '%s' is out of range, ... */ | 2145 | /* conv. of '%s' to '%s' is out of range, ... */ | |
2146 | warning(295, | 2146 | warning(295, | |
2147 | type_name(gettyp(ot)), type_name(tp), arg); | 2147 | type_name(gettyp(ot)), type_name(tp), arg); | |
2148 | } else { | 2148 | } else { | |
2149 | /* conversion of '%s' to '%s' is out of range */ | 2149 | /* conversion of '%s' to '%s' is out of range */ | |
2150 | warning(119, | 2150 | warning(119, | |
2151 | type_name(gettyp(ot)), type_name(tp)); | 2151 | type_name(gettyp(ot)), type_name(tp)); | |
@@ -2299,27 +2299,27 @@ build_struct_access(op_t op, tnode_t *ln | @@ -2299,27 +2299,27 @@ build_struct_access(op_t op, tnode_t *ln | |||
2299 | ln = convert(NOOP, 0, tincref(gettyp(VOID), PTR), ln); | 2299 | ln = convert(NOOP, 0, tincref(gettyp(VOID), PTR), ln); | |
2300 | } | 2300 | } | |
2301 | 2301 | |||
2302 | #if PTRDIFF_IS_LONG | 2302 | #if PTRDIFF_IS_LONG | |
2303 | ctn = new_int_const_node(LONG, rn->tn_sym->s_value.v_quad / CHAR_BIT); | 2303 | ctn = new_int_const_node(LONG, rn->tn_sym->s_value.v_quad / CHAR_BIT); | |
2304 | #else | 2304 | #else | |
2305 | ctn = new_int_const_node(INT, rn->tn_sym->s_value.v_quad / CHAR_BIT); | 2305 | ctn = new_int_const_node(INT, rn->tn_sym->s_value.v_quad / CHAR_BIT); | |
2306 | #endif | 2306 | #endif | |
2307 | 2307 | |||
2308 | ntn = new_tnode(PLUS, tincref(rn->tn_type, PTR), ln, ctn); | 2308 | ntn = new_tnode(PLUS, tincref(rn->tn_type, PTR), ln, ctn); | |
2309 | if (ln->tn_op == CON) | 2309 | if (ln->tn_op == CON) | |
2310 | ntn = fold(ntn); | 2310 | ntn = fold(ntn); | |
2311 | 2311 | |||
2312 | if (rn->tn_type->t_isfield) { | 2312 | if (rn->tn_type->t_bitfield) { | |
2313 | ntn = new_tnode(FSEL, ntn->tn_type->t_subt, ntn, NULL); | 2313 | ntn = new_tnode(FSEL, ntn->tn_type->t_subt, ntn, NULL); | |
2314 | } else { | 2314 | } else { | |
2315 | ntn = new_tnode(STAR, ntn->tn_type->t_subt, ntn, NULL); | 2315 | ntn = new_tnode(STAR, ntn->tn_type->t_subt, ntn, NULL); | |
2316 | } | 2316 | } | |
2317 | 2317 | |||
2318 | if (nolval) | 2318 | if (nolval) | |
2319 | ntn->tn_lvalue = 0; | 2319 | ntn->tn_lvalue = 0; | |
2320 | 2320 | |||
2321 | return ntn; | 2321 | return ntn; | |
2322 | } | 2322 | } | |
2323 | 2323 | |||
2324 | /* | 2324 | /* | |
2325 | * Create a node for INCAFT, INCBEF, DECAFT and DECBEF. | 2325 | * Create a node for INCAFT, INCBEF, DECAFT and DECBEF. | |
@@ -2581,27 +2581,27 @@ build_assignment(op_t op, tnode_t *ln, t | @@ -2581,27 +2581,27 @@ build_assignment(op_t op, tnode_t *ln, t | |||
2581 | return NULL; | 2581 | return NULL; | |
2582 | } | 2582 | } | |
2583 | } | 2583 | } | |
2584 | 2584 | |||
2585 | if (op == SHLASS) { | 2585 | if (op == SHLASS) { | |
2586 | if (psize(lt) < psize(rt)) { | 2586 | if (psize(lt) < psize(rt)) { | |
2587 | if (hflag) | 2587 | if (hflag) | |
2588 | /* semantics of '%s' change in ANSI C; ... */ | 2588 | /* semantics of '%s' change in ANSI C; ... */ | |
2589 | warning(118, "<<="); | 2589 | warning(118, "<<="); | |
2590 | } | 2590 | } | |
2591 | } else if (op != SHRASS) { | 2591 | } else if (op != SHRASS) { | |
2592 | if (op == ASSIGN || lt != PTR) { | 2592 | if (op == ASSIGN || lt != PTR) { | |
2593 | if (lt != rt || | 2593 | if (lt != rt || | |
2594 | (ln->tn_type->t_isfield && rn->tn_op == CON)) { | 2594 | (ln->tn_type->t_bitfield && rn->tn_op == CON)) { | |
2595 | rn = convert(op, 0, ln->tn_type, rn); | 2595 | rn = convert(op, 0, ln->tn_type, rn); | |
2596 | rt = lt; | 2596 | rt = lt; | |
2597 | } | 2597 | } | |
2598 | } | 2598 | } | |
2599 | } | 2599 | } | |
2600 | 2600 | |||
2601 | ntn = new_tnode(op, ln->tn_type, ln, rn); | 2601 | ntn = new_tnode(op, ln->tn_type, ln, rn); | |
2602 | 2602 | |||
2603 | return ntn; | 2603 | return ntn; | |
2604 | } | 2604 | } | |
2605 | 2605 | |||
2606 | /* | 2606 | /* | |
2607 | * Get length of type tp->t_subt. | 2607 | * Get length of type tp->t_subt. | |
@@ -3036,27 +3036,27 @@ tsize(type_t *tp) | @@ -3036,27 +3036,27 @@ tsize(type_t *tp) | |||
3036 | error(143); | 3036 | error(143); | |
3037 | elsz = 1; | 3037 | elsz = 1; | |
3038 | } else { | 3038 | } else { | |
3039 | elsz = tp->t_str->size; | 3039 | elsz = tp->t_str->size; | |
3040 | } | 3040 | } | |
3041 | break; | 3041 | break; | |
3042 | case ENUM: | 3042 | case ENUM: | |
3043 | if (incompl(tp)) { | 3043 | if (incompl(tp)) { | |
3044 | /* cannot take size/alignment of incomplete type */ | 3044 | /* cannot take size/alignment of incomplete type */ | |
3045 | warning(143); | 3045 | warning(143); | |
3046 | } | 3046 | } | |
3047 | /* FALLTHROUGH */ | 3047 | /* FALLTHROUGH */ | |
3048 | default: | 3048 | default: | |
3049 | if (tp->t_isfield) { | 3049 | if (tp->t_bitfield) { | |
3050 | /* cannot take size/alignment of bit-field */ | 3050 | /* cannot take size/alignment of bit-field */ | |
3051 | error(145); | 3051 | error(145); | |
3052 | } | 3052 | } | |
3053 | if (tp->t_tspec == VOID) { | 3053 | if (tp->t_tspec == VOID) { | |
3054 | /* cannot take size/alignment of void */ | 3054 | /* cannot take size/alignment of void */ | |
3055 | error(146); | 3055 | error(146); | |
3056 | elsz = 1; | 3056 | elsz = 1; | |
3057 | } else { | 3057 | } else { | |
3058 | elsz = size(tp->t_tspec); | 3058 | elsz = size(tp->t_tspec); | |
3059 | lint_assert(elsz > 0); | 3059 | lint_assert(elsz > 0); | |
3060 | } | 3060 | } | |
3061 | break; | 3061 | break; | |
3062 | } | 3062 | } | |
@@ -3082,27 +3082,27 @@ build_alignof(type_t *tp) | @@ -3082,27 +3082,27 @@ build_alignof(type_t *tp) | |||
3082 | return 0; | 3082 | return 0; | |
3083 | 3083 | |||
3084 | case STRUCT: | 3084 | case STRUCT: | |
3085 | case UNION: | 3085 | case UNION: | |
3086 | if (incompl(tp)) { | 3086 | if (incompl(tp)) { | |
3087 | /* cannot take size/alignment of incomplete type */ | 3087 | /* cannot take size/alignment of incomplete type */ | |
3088 | error(143); | 3088 | error(143); | |
3089 | return 0; | 3089 | return 0; | |
3090 | } | 3090 | } | |
3091 | break; | 3091 | break; | |
3092 | case ENUM: | 3092 | case ENUM: | |
3093 | break; | 3093 | break; | |
3094 | default: | 3094 | default: | |
3095 | if (tp->t_isfield) { | 3095 | if (tp->t_bitfield) { | |
3096 | /* cannot take size/alignment of bit-field */ | 3096 | /* cannot take size/alignment of bit-field */ | |
3097 | error(145); | 3097 | error(145); | |
3098 | return 0; | 3098 | return 0; | |
3099 | } | 3099 | } | |
3100 | if (tp->t_tspec == VOID) { | 3100 | if (tp->t_tspec == VOID) { | |
3101 | /* cannot take size/alignment of void */ | 3101 | /* cannot take size/alignment of void */ | |
3102 | error(146); | 3102 | error(146); | |
3103 | return 0; | 3103 | return 0; | |
3104 | } | 3104 | } | |
3105 | break; | 3105 | break; | |
3106 | } | 3106 | } | |
3107 | 3107 | |||
3108 | #if SIZEOF_IS_ULONG | 3108 | #if SIZEOF_IS_ULONG |