lint: use bool instead of u_int:1 in structures Better late than never.diff -r1.20 -r1.21 src/usr.bin/xlint/common/lint.h
(rillig)
--- src/usr.bin/xlint/common/lint.h 2021/01/01 11:58:03 1.20
+++ src/usr.bin/xlint/common/lint.h 2021/01/02 01:06:15 1.21
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: lint.h,v 1.20 2021/01/01 11:58:03 rillig Exp $ */ | 1 | /* $NetBSD: lint.h,v 1.21 2021/01/02 01:06:15 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. | |
@@ -28,29 +28,30 @@ | @@ -28,29 +28,30 @@ | |||
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 | #else | 36 | #else | |
37 | #define HAVE_DECL_SYS_SIGNAME 1 | 37 | #define HAVE_DECL_SYS_SIGNAME 1 | |
38 | #endif | 38 | #endif | |
39 | 39 | |||
40 | #include <sys/types.h> | 40 | #include <sys/types.h> | |
41 | #include <stddef.h> | |||
42 | #include <err.h> | 41 | #include <err.h> | |
43 | #include <inttypes.h> | 42 | #include <inttypes.h> | |
43 | #include <stdbool.h> | |||
44 | #include <stddef.h> | |||
44 | #include <stdio.h> | 45 | #include <stdio.h> | |
45 | 46 | |||
46 | #include "param.h" | 47 | #include "param.h" | |
47 | 48 | |||
48 | /* | 49 | /* | |
49 | * Type specifiers, used in type structures (type_t) and elsewhere. | 50 | * Type specifiers, used in type structures (type_t) and elsewhere. | |
50 | */ | 51 | */ | |
51 | typedef enum { | 52 | typedef enum { | |
52 | NOTSPEC = 0, | 53 | NOTSPEC = 0, | |
53 | SIGNED, /* keyword "signed", only used in the parser */ | 54 | SIGNED, /* keyword "signed", only used in the parser */ | |
54 | UNSIGN, /* keyword "unsigned", only used in the parser */ | 55 | UNSIGN, /* keyword "unsigned", only used in the parser */ | |
55 | BOOL, /* _Bool */ | 56 | BOOL, /* _Bool */ | |
56 | CHAR, /* char */ | 57 | CHAR, /* char */ | |
@@ -85,32 +86,32 @@ typedef enum { | @@ -85,32 +86,32 @@ typedef enum { | |||
85 | #define NTSPEC (LCOMPLEX + 1) | 86 | #define NTSPEC (LCOMPLEX + 1) | |
86 | } tspec_t; | 87 | } tspec_t; | |
87 | 88 | |||
88 | 89 | |||
89 | /* | 90 | /* | |
90 | * size of types, name and classification | 91 | * size of types, name and classification | |
91 | */ | 92 | */ | |
92 | typedef struct { | 93 | typedef struct { | |
93 | size_t tt_sz; /* size in bits */ | 94 | size_t tt_sz; /* size in bits */ | |
94 | size_t tt_psz; /* size, different from tt_sz | 95 | size_t tt_psz; /* size, different from tt_sz | |
95 | if pflag is set */ | 96 | if pflag is set */ | |
96 | tspec_t tt_signed_counterpart; | 97 | tspec_t tt_signed_counterpart; | |
97 | tspec_t tt_unsigned_counterpart; | 98 | tspec_t tt_unsigned_counterpart; | |
98 | u_int tt_is_int : 1; /* 1 if integer type */ | 99 | bool tt_is_int : 1; /* integer type */ | |
99 | u_int tt_is_uint : 1; /* 1 if unsigned integer type */ | 100 | bool tt_is_uint : 1; /* unsigned integer type */ | |
100 | u_int tt_is_float : 1; /* 1 if floating point type */ | 101 | bool tt_is_float : 1; /* floating point type */ | |
101 | u_int tt_is_arith : 1; /* 1 if arithmetic type */ | 102 | bool tt_is_arith : 1; /* arithmetic type */ | |
102 | u_int tt_is_scalar : 1; /* 1 if scalar type */ | 103 | bool tt_is_scalar : 1; /* scalar type */ | |
103 | u_int tt_is_complex : 1; /* 1 if complex type */ | 104 | bool tt_is_complex : 1; /* complex type */ | |
104 | const char *tt_name; /* name of the type */ | 105 | const char *tt_name; /* name of the type */ | |
105 | } ttab_t; | 106 | } ttab_t; | |
106 | 107 | |||
107 | #define size(t) (ttab[t].tt_sz) | 108 | #define size(t) (ttab[t].tt_sz) | |
108 | #define psize(t) (ttab[t].tt_psz) | 109 | #define psize(t) (ttab[t].tt_psz) | |
109 | #define signed_type(t) (ttab[t].tt_signed_counterpart) | 110 | #define signed_type(t) (ttab[t].tt_signed_counterpart) | |
110 | #define unsigned_type(t) (ttab[t].tt_unsigned_counterpart) | 111 | #define unsigned_type(t) (ttab[t].tt_unsigned_counterpart) | |
111 | #define tspec_is_int(t) (ttab[t].tt_is_int) | 112 | #define tspec_is_int(t) (ttab[t].tt_is_int) | |
112 | #define tspec_is_uint(t) (ttab[t].tt_is_uint) | 113 | #define tspec_is_uint(t) (ttab[t].tt_is_uint) | |
113 | #define tspec_is_float(t) (ttab[t].tt_is_float) | 114 | #define tspec_is_float(t) (ttab[t].tt_is_float) | |
114 | #define tspec_is_arith(t) (ttab[t].tt_is_arith) | 115 | #define tspec_is_arith(t) (ttab[t].tt_is_arith) | |
115 | #define tspec_is_complex(t) (ttab[t].tt_is_complex) | 116 | #define tspec_is_complex(t) (ttab[t].tt_is_complex) | |
116 | #define tspec_is_scalar(t) (ttab[t].tt_is_scalar) | 117 | #define tspec_is_scalar(t) (ttab[t].tt_is_scalar) |
--- src/usr.bin/xlint/lint1/init.c 2021/01/01 20:02:56 1.55
+++ src/usr.bin/xlint/lint1/init.c 2021/01/02 01:06:15 1.56
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: init.c,v 1.55 2021/01/01 20:02:56 rillig Exp $ */ | 1 | /* $NetBSD: init.c,v 1.56 2021/01/02 01:06:15 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.55 2021/01/01 20:02:56 rillig Exp $"); | 40 | __RCSID("$NetBSD: init.c,v 1.56 2021/01/02 01:06:15 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 | |
@@ -55,29 +55,29 @@ __RCSID("$NetBSD: init.c,v 1.55 2021/01/ | @@ -55,29 +55,29 @@ __RCSID("$NetBSD: init.c,v 1.55 2021/01/ | |||
55 | * of non-leaf structs may thus appear repeatedly, as demonstrated in | 55 | * of non-leaf structs may thus appear repeatedly, as demonstrated in | |
56 | * d_init_pop_member.c. | 56 | * d_init_pop_member.c. | |
57 | * | 57 | * | |
58 | * XXX: During initialization, there may be members of the top-level struct | 58 | * XXX: During initialization, there may be members of the top-level struct | |
59 | * that are partially initialized. The simple i_remaining cannot model this | 59 | * that are partially initialized. The simple i_remaining cannot model this | |
60 | * appropriately. | 60 | * appropriately. | |
61 | * | 61 | * | |
62 | * See C99 6.7.8, which spans 6 pages full of tricky details and carefully | 62 | * See C99 6.7.8, which spans 6 pages full of tricky details and carefully | |
63 | * selected examples. | 63 | * selected examples. | |
64 | */ | 64 | */ | |
65 | typedef struct istk { | 65 | typedef struct istk { | |
66 | type_t *i_type; /* type of initialisation */ | 66 | type_t *i_type; /* type of initialisation */ | |
67 | type_t *i_subt; /* type of next level */ | 67 | type_t *i_subt; /* type of next level */ | |
68 | u_int i_brace : 1; /* need } for pop */ | 68 | bool i_brace : 1; /* need } for pop */ | |
69 | u_int i_nolimit : 1; /* incomplete array type */ | 69 | bool i_nolimit : 1; /* incomplete array type */ | |
70 | u_int i_namedmem : 1; /* has c9x named members */ | 70 | bool i_namedmem : 1; /* has c9x named members */ | |
71 | sym_t *i_mem; /* next structure member */ | 71 | sym_t *i_mem; /* next structure member */ | |
72 | int i_remaining; /* # of remaining elements */ | 72 | int i_remaining; /* # of remaining elements */ | |
73 | struct istk *i_next; /* previous level */ | 73 | struct istk *i_next; /* previous level */ | |
74 | } istk_t; | 74 | } istk_t; | |
75 | 75 | |||
76 | /* | 76 | /* | |
77 | * The names for a nested C99 initialization designator, in a circular list. | 77 | * The names for a nested C99 initialization designator, in a circular list. | |
78 | * | 78 | * | |
79 | * Example: | 79 | * Example: | |
80 | * struct stat st = { | 80 | * struct stat st = { | |
81 | * .st_size = 123, | 81 | * .st_size = 123, | |
82 | * .st_mtim.tv_sec = 45, | 82 | * .st_mtim.tv_sec = 45, | |
83 | * .st_mtim.tv_nsec | 83 | * .st_mtim.tv_nsec |
--- src/usr.bin/xlint/lint1/lint1.h 2021/01/01 19:15:58 1.46
+++ src/usr.bin/xlint/lint1/lint1.h 2021/01/02 01:06:15 1.47
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: lint1.h,v 1.46 2021/01/01 19:15:58 rillig Exp $ */ | 1 | /* $NetBSD: lint1.h,v 1.47 2021/01/02 01:06:15 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 | |
@@ -117,57 +117,57 @@ typedef struct { | @@ -117,57 +117,57 @@ typedef struct { | |||
117 | /* | 117 | /* | |
118 | * Structures of type str_t uniqely identify structures. This can't | 118 | * Structures of type str_t uniqely identify structures. This can't | |
119 | * be done in structures of type type_t, because these are copied | 119 | * be done in structures of type type_t, because these are copied | |
120 | * if they must be modified. So it would not be possible to check | 120 | * if they must be modified. So it would not be possible to check | |
121 | * if two structures are identical by comparing the pointers to | 121 | * if two structures are identical by comparing the pointers to | |
122 | * the type structures. | 122 | * the type structures. | |
123 | * | 123 | * | |
124 | * The typename is used if the structure is unnamed to identify | 124 | * The typename is used if the structure is unnamed to identify | |
125 | * the structure type in pass 2. | 125 | * the structure type in pass 2. | |
126 | */ | 126 | */ | |
127 | typedef struct { | 127 | typedef struct { | |
128 | u_int size; /* size in bit */ | 128 | u_int size; /* size in bit */ | |
129 | u_int align : 15; /* alignment in bit */ | 129 | u_int align : 15; /* alignment in bit */ | |
130 | u_int sincompl : 1; /* set if incomplete type */ | 130 | bool sincompl : 1; /* set if incomplete type */ | |
131 | struct sym *memb; /* list of members */ | 131 | struct sym *memb; /* list of members */ | |
132 | struct sym *stag; /* symbol table entry of tag */ | 132 | struct sym *stag; /* symbol table entry of tag */ | |
133 | struct sym *stdef; /* symbol table entry of first typename */ | 133 | struct sym *stdef; /* symbol table entry of first typename */ | |
134 | } str_t; | 134 | } str_t; | |
135 | 135 | |||
136 | /* | 136 | /* | |
137 | * same as above for enums | 137 | * same as above for enums | |
138 | */ | 138 | */ | |
139 | typedef struct { | 139 | typedef struct { | |
140 | u_int eincompl : 1; /* incomplete enum type */ | 140 | bool eincompl : 1; /* incomplete enum type */ | |
141 | struct sym *elem; /* list of enumerators */ | 141 | struct sym *elem; /* list of enumerators */ | |
142 | struct sym *etag; /* symbol table entry of tag */ | 142 | struct sym *etag; /* symbol table entry of tag */ | |
143 | struct sym *etdef; /* symbol table entry of first typename */ | 143 | struct sym *etdef; /* symbol table entry of first typename */ | |
144 | } tenum_t; | 144 | } tenum_t; | |
145 | 145 | |||
146 | /* | 146 | /* | |
147 | * Types are represented by concatenation of structures of type type_t | 147 | * Types are represented by concatenation of structures of type type_t | |
148 | * via t_subt. | 148 | * via t_subt. | |
149 | */ | 149 | */ | |
150 | struct type { | 150 | struct type { | |
151 | tspec_t t_tspec; /* type specifier */ | 151 | tspec_t t_tspec; /* type specifier */ | |
152 | u_int t_aincompl : 1; /* incomplete array type */ | 152 | bool t_aincompl : 1; /* incomplete array type */ | |
153 | u_int t_const : 1; /* const modifier */ | 153 | bool t_const : 1; /* const modifier */ | |
154 | u_int t_volatile : 1; /* volatile modifier */ | 154 | bool t_volatile : 1; /* volatile modifier */ | |
155 | u_int t_proto : 1; /* function prototype (t_args valid) */ | 155 | bool t_proto : 1; /* function prototype (t_args valid) */ | |
156 | u_int t_vararg : 1; /* prototype with ... */ | 156 | bool t_vararg : 1; /* prototype with ... */ | |
157 | u_int t_typedef : 1; /* type defined with typedef */ | 157 | bool t_typedef : 1; /* type defined with typedef */ | |
158 | u_int t_isfield : 1; /* type is bitfield */ | 158 | bool t_isfield : 1; /* type is bitfield */ | |
159 | u_int t_isenum : 1; /* type is (or was) enum (t_enum valid) */ | 159 | bool t_isenum : 1; /* type is (or was) enum (t_enum valid) */ | |
160 | u_int t_ispacked : 1; /* type is packed */ | 160 | bool t_ispacked : 1; /* type is packed */ | |
161 | union { | 161 | union { | |
162 | int _t_dim; /* dimension */ | 162 | int _t_dim; /* dimension */ | |
163 | str_t *_t_str; /* struct/union tag */ | 163 | str_t *_t_str; /* struct/union tag */ | |
164 | tenum_t *_t_enum; /* enum tag */ | 164 | tenum_t *_t_enum; /* enum tag */ | |
165 | struct sym *_t_args; /* arguments (if t_proto) */ | 165 | struct sym *_t_args; /* arguments (if t_proto) */ | |
166 | } t_u; | 166 | } t_u; | |
167 | struct { | 167 | struct { | |
168 | u_int _t_flen : 8; /* length of bit-field */ | 168 | u_int _t_flen : 8; /* length of bit-field */ | |
169 | u_int _t_foffs : 24; /* offset of bit-field */ | 169 | u_int _t_foffs : 24; /* offset of bit-field */ | |
170 | } t_b; | 170 | } t_b; | |
171 | struct type *t_subt; /* element type (arrays), return value | 171 | struct type *t_subt; /* element type (arrays), return value | |
172 | (functions), or type pointer points to */ | 172 | (functions), or type pointer points to */ | |
173 | }; | 173 | }; | |
@@ -216,36 +216,36 @@ typedef enum { | @@ -216,36 +216,36 @@ typedef enum { | |||
216 | * symbol table entry | 216 | * symbol table entry | |
217 | */ | 217 | */ | |
218 | typedef struct sym { | 218 | typedef struct sym { | |
219 | const char *s_name; | 219 | const char *s_name; | |
220 | const char *s_rename; /* renamed symbol's given name */ | 220 | const char *s_rename; /* renamed symbol's given name */ | |
221 | pos_t s_def_pos; /* position of last (prototype) definition, | 221 | pos_t s_def_pos; /* position of last (prototype) definition, | |
222 | prototype declaration, no-prototype-def., | 222 | prototype declaration, no-prototype-def., | |
223 | tentative definition or declaration, | 223 | tentative definition or declaration, | |
224 | in this order */ | 224 | in this order */ | |
225 | pos_t s_set_pos; /* position of first initialisation */ | 225 | pos_t s_set_pos; /* position of first initialisation */ | |
226 | pos_t s_use_pos; /* position of first use */ | 226 | pos_t s_use_pos; /* position of first use */ | |
227 | symt_t s_kind; /* type of symbol */ | 227 | symt_t s_kind; /* type of symbol */ | |
228 | void *s_keyword; | 228 | void *s_keyword; | |
229 | u_int s_bitfield : 1; | 229 | bool s_bitfield : 1; | |
230 | u_int s_set : 1; /* variable set, label defined */ | 230 | bool s_set : 1; /* variable set, label defined */ | |
231 | u_int s_used : 1; /* variable/label used */ | 231 | bool s_used : 1; /* variable/label used */ | |
232 | u_int s_arg : 1; /* symbol is function argument */ | 232 | bool s_arg : 1; /* symbol is function argument */ | |
233 | u_int s_reg : 1; /* symbol is register variable */ | 233 | bool s_reg : 1; /* symbol is register variable */ | |
234 | u_int s_defarg : 1; /* undefined symbol in old style function | 234 | bool s_defarg : 1; /* undefined symbol in old style function | |
235 | definition */ | 235 | definition */ | |
236 | u_int s_rimpl : 1; /* return value of function implicit decl. */ | 236 | bool s_rimpl : 1; /* return value of function implicit decl. */ | |
237 | u_int s_osdef : 1; /* symbol stems from old style function def. */ | 237 | bool s_osdef : 1; /* symbol stems from old style function def. */ | |
238 | u_int s_inline : 1; /* true if this is an inline function */ | 238 | bool s_inline : 1; /* true if this is an inline function */ | |
239 | struct sym *s_ext_sym; /* for local declared external symbols pointer | 239 | struct sym *s_ext_sym; /* for local declared external symbols pointer | |
240 | to external symbol with same name */ | 240 | to external symbol with same name */ | |
241 | def_t s_def; /* declared, tentative defined, defined */ | 241 | def_t s_def; /* declared, tentative defined, defined */ | |
242 | scl_t s_scl; /* storage class */ | 242 | scl_t s_scl; /* storage class */ | |
243 | int s_blklev; /* level of declaration, -1 if not in symbol | 243 | int s_blklev; /* level of declaration, -1 if not in symbol | |
244 | table */ | 244 | table */ | |
245 | type_t *s_type; | 245 | type_t *s_type; | |
246 | val_t s_value; /* value (if enum constant) */ | 246 | val_t s_value; /* value (if enum constant) */ | |
247 | union { | 247 | union { | |
248 | str_t *_s_st; /* tag, if it is a struct/union member */ | 248 | str_t *_s_st; /* tag, if it is a struct/union member */ | |
249 | tenum_t *_s_et; /* tag, if it is an enumerator */ | 249 | tenum_t *_s_et; /* tag, if it is an enumerator */ | |
250 | tspec_t _s_tsp; /* type (only for keywords) */ | 250 | tspec_t _s_tsp; /* type (only for keywords) */ | |
251 | tqual_t _s_tqu; /* qualifier (only for keywords) */ | 251 | tqual_t _s_tqu; /* qualifier (only for keywords) */ | |
@@ -274,29 +274,29 @@ typedef struct sbuf { | @@ -274,29 +274,29 @@ typedef struct sbuf { | |||
274 | size_t sb_len; /* length (without '\0') */ | 274 | size_t sb_len; /* length (without '\0') */ | |
275 | int sb_hash; /* hash value */ | 275 | int sb_hash; /* hash value */ | |
276 | sym_t *sb_sym; /* symbol table entry */ | 276 | sym_t *sb_sym; /* symbol table entry */ | |
277 | struct sbuf *sb_next; /* for freelist */ | 277 | struct sbuf *sb_next; /* for freelist */ | |
278 | } sbuf_t; | 278 | } sbuf_t; | |
279 | 279 | |||
280 | 280 | |||
281 | /* | 281 | /* | |
282 | * tree node | 282 | * tree node | |
283 | */ | 283 | */ | |
284 | typedef struct tnode { | 284 | typedef struct tnode { | |
285 | op_t tn_op; /* operator */ | 285 | op_t tn_op; /* operator */ | |
286 | type_t *tn_type; /* type */ | 286 | type_t *tn_type; /* type */ | |
287 | u_int tn_lvalue : 1; /* node is lvalue */ | 287 | bool tn_lvalue : 1; /* node is lvalue */ | |
288 | u_int tn_cast : 1; /* if tn_op == CVT, it's an explicit cast */ | 288 | bool tn_cast : 1; /* if tn_op == CVT, it's an explicit cast */ | |
289 | u_int tn_parenthesized : 1; /* node parenthesized */ | 289 | bool tn_parenthesized : 1; | |
290 | union { | 290 | union { | |
291 | struct { | 291 | struct { | |
292 | struct tnode *_tn_left; /* (left) operand */ | 292 | struct tnode *_tn_left; /* (left) operand */ | |
293 | struct tnode *_tn_right; /* right operand */ | 293 | struct tnode *_tn_right; /* right operand */ | |
294 | } tn_s; | 294 | } tn_s; | |
295 | sym_t *_tn_sym; /* symbol if op == NAME */ | 295 | sym_t *_tn_sym; /* symbol if op == NAME */ | |
296 | val_t *_tn_val; /* value if op == CON */ | 296 | val_t *_tn_val; /* value if op == CON */ | |
297 | strg_t *_tn_string; /* string if op == STRING */ | 297 | strg_t *_tn_string; /* string if op == STRING */ | |
298 | } tn_u; | 298 | } tn_u; | |
299 | } tnode_t; | 299 | } tnode_t; | |
300 | 300 | |||
301 | #define tn_left tn_u.tn_s._tn_left | 301 | #define tn_left tn_u.tn_s._tn_left | |
302 | #define tn_right tn_u.tn_s._tn_right | 302 | #define tn_right tn_u.tn_s._tn_right | |
@@ -322,82 +322,82 @@ typedef struct tnode { | @@ -322,82 +322,82 @@ typedef struct tnode { | |||
322 | */ | 322 | */ | |
323 | typedef struct dinfo { | 323 | typedef struct dinfo { | |
324 | tspec_t d_atyp; /* VOID, CHAR, INT, or COMPLEX */ | 324 | tspec_t d_atyp; /* VOID, CHAR, INT, or COMPLEX */ | |
325 | tspec_t d_cmod; /* FLOAT, or DOUBLE */ | 325 | tspec_t d_cmod; /* FLOAT, or DOUBLE */ | |
326 | tspec_t d_smod; /* SIGNED or UNSIGN */ | 326 | tspec_t d_smod; /* SIGNED or UNSIGN */ | |
327 | tspec_t d_lmod; /* SHORT, LONG or QUAD */ | 327 | tspec_t d_lmod; /* SHORT, LONG or QUAD */ | |
328 | scl_t d_scl; /* storage class */ | 328 | scl_t d_scl; /* storage class */ | |
329 | type_t *d_type; /* after deftyp() pointer to the type used | 329 | type_t *d_type; /* after deftyp() pointer to the type used | |
330 | for all declarators */ | 330 | for all declarators */ | |
331 | sym_t *d_rdcsym; /* redeclared symbol */ | 331 | sym_t *d_rdcsym; /* redeclared symbol */ | |
332 | int d_offset; /* offset of next structure member */ | 332 | int d_offset; /* offset of next structure member */ | |
333 | int d_stralign; /* alignment required for current structure */ | 333 | int d_stralign; /* alignment required for current structure */ | |
334 | scl_t d_ctx; /* context of declaration */ | 334 | scl_t d_ctx; /* context of declaration */ | |
335 | u_int d_const : 1; /* const in declaration specifiers */ | 335 | bool d_const : 1; /* const in declaration specifiers */ | |
336 | u_int d_volatile : 1; /* volatile in declaration specifiers */ | 336 | bool d_volatile : 1; /* volatile in declaration specifiers */ | |
337 | u_int d_inline : 1; /* inline in declaration specifiers */ | 337 | bool d_inline : 1; /* inline in declaration specifiers */ | |
338 | u_int d_mscl : 1; /* multiple storage classes */ | 338 | bool d_mscl : 1; /* multiple storage classes */ | |
339 | u_int d_terr : 1; /* invalid type combination */ | 339 | bool d_terr : 1; /* invalid type combination */ | |
340 | u_int d_nedecl : 1; /* 1 if at least a tag is declared */ | 340 | bool d_nedecl : 1; /* if at least one tag is declared */ | |
341 | u_int d_vararg : 1; /* ... in in current function decl. */ | 341 | bool d_vararg : 1; /* ... in in current function decl. */ | |
342 | u_int d_proto : 1; /* current funct. decl. is prototype */ | 342 | bool d_proto : 1; /* current function decl. is prototype */ | |
343 | u_int d_notyp : 1; /* set if no type specifier was present */ | 343 | bool d_notyp : 1; /* set if no type specifier was present */ | |
344 | u_int d_asm : 1; /* set if d_ctx == AUTO and asm() present */ | 344 | bool d_asm : 1; /* set if d_ctx == AUTO and asm() present */ | |
345 | u_int d_ispacked : 1; /* packed */ | 345 | bool d_ispacked : 1; /* packed */ | |
346 | u_int d_used : 1; /* used */ | 346 | bool d_used : 1; /* used */ | |
347 | type_t *d_tagtyp; /* tag during member declaration */ | 347 | type_t *d_tagtyp; /* tag during member declaration */ | |
348 | sym_t *d_fargs; /* list of arguments during function def. */ | 348 | sym_t *d_fargs; /* list of arguments during function def. */ | |
349 | pos_t d_fdpos; /* position of function definition */ | 349 | pos_t d_fdpos; /* position of function definition */ | |
350 | sym_t *d_dlsyms; /* first symbol declared at this level */ | 350 | sym_t *d_dlsyms; /* first symbol declared at this level */ | |
351 | sym_t **d_ldlsym; /* points to s_dlnxt in last symbol decl. | 351 | sym_t **d_ldlsym; /* points to s_dlnxt in last symbol decl. | |
352 | at this level */ | 352 | at this level */ | |
353 | sym_t *d_fpsyms; /* symbols defined in prototype */ | 353 | sym_t *d_fpsyms; /* symbols defined in prototype */ | |
354 | struct dinfo *d_next; /* next level */ | 354 | struct dinfo *d_next; /* next level */ | |
355 | } dinfo_t; | 355 | } dinfo_t; | |
356 | 356 | |||
357 | /* | 357 | /* | |
358 | * Used to collect information about pointers and qualifiers in | 358 | * Used to collect information about pointers and qualifiers in | |
359 | * declarators. | 359 | * declarators. | |
360 | */ | 360 | */ | |
361 | typedef struct pqinf { | 361 | typedef struct pqinf { | |
362 | int p_pcnt; /* number of asterisks */ | 362 | int p_pcnt; /* number of asterisks */ | |
363 | u_int p_const : 1; | 363 | bool p_const : 1; | |
364 | u_int p_volatile : 1; | 364 | bool p_volatile : 1; | |
365 | struct pqinf *p_next; | 365 | struct pqinf *p_next; | |
366 | } pqinf_t; | 366 | } pqinf_t; | |
367 | 367 | |||
368 | /* | 368 | /* | |
369 | * Case values are stored in a list of type clst_t. | 369 | * Case values are stored in a list of type clst_t. | |
370 | */ | 370 | */ | |
371 | typedef struct clst { | 371 | typedef struct clst { | |
372 | val_t cl_val; | 372 | val_t cl_val; | |
373 | struct clst *cl_next; | 373 | struct clst *cl_next; | |
374 | } clst_t; | 374 | } clst_t; | |
375 | 375 | |||
376 | /* | 376 | /* | |
377 | * Used to keep information about nested control statements. | 377 | * Used to keep information about nested control statements. | |
378 | */ | 378 | */ | |
379 | typedef struct cstk { | 379 | typedef struct cstk { | |
380 | int c_env; /* type of statement (T_IF, ...) */ | 380 | int c_env; /* type of statement (T_IF, ...) */ | |
381 | u_int c_loop : 1; /* continue && break are valid */ | 381 | bool c_loop : 1; /* continue && break are valid */ | |
382 | u_int c_switch : 1; /* case && break are valid */ | 382 | bool c_switch : 1; /* case && break are valid */ | |
383 | u_int c_break : 1; /* loop/switch has break */ | 383 | bool c_break : 1; /* loop/switch has break */ | |
384 | u_int c_cont : 1; /* loop has continue */ | 384 | bool c_cont : 1; /* loop has continue */ | |
385 | u_int c_default : 1; /* switch has default */ | 385 | bool c_default : 1; /* switch has default */ | |
386 | u_int c_infinite : 1; /* break condition always false | 386 | bool c_infinite : 1; /* break condition always false | |
387 | (for (;;), while (1)) */ | 387 | (for (;;), while (1)) */ | |
388 | u_int c_rchif : 1; /* end of if-branch reached */ | 388 | bool c_rchif : 1; /* end of if-branch reached */ | |
389 | u_int c_noretval : 1; /* had "return;" */ | 389 | bool c_noretval : 1; /* had "return;" */ | |
390 | u_int c_retval : 1; /* had "return (e);" */ | 390 | bool c_retval : 1; /* had "return (e);" */ | |
391 | type_t *c_swtype; /* type of switch expression */ | 391 | type_t *c_swtype; /* type of switch expression */ | |
392 | clst_t *c_clst; /* list of case values */ | 392 | clst_t *c_clst; /* list of case values */ | |
393 | struct mbl *c_fexprm; /* saved memory for end of loop | 393 | struct mbl *c_fexprm; /* saved memory for end of loop | |
394 | expression in for() */ | 394 | expression in for() */ | |
395 | tnode_t *c_f3expr; /* end of loop expr in for() */ | 395 | tnode_t *c_f3expr; /* end of loop expr in for() */ | |
396 | pos_t c_fpos; /* position of end of loop expr */ | 396 | pos_t c_fpos; /* position of end of loop expr */ | |
397 | pos_t c_cfpos; /* same for csrc_pos */ | 397 | pos_t c_cfpos; /* same for csrc_pos */ | |
398 | struct cstk *c_next; /* outer control statement */ | 398 | struct cstk *c_next; /* outer control statement */ | |
399 | } cstk_t; | 399 | } cstk_t; | |
400 | 400 | |||
401 | typedef struct { | 401 | typedef struct { | |
402 | size_t lo; | 402 | size_t lo; | |
403 | size_t hi; | 403 | size_t hi; |
--- src/usr.bin/xlint/lint1/op.h 2020/12/28 19:38:54 1.7
+++ src/usr.bin/xlint/lint1/op.h 2021/01/02 01:06:15 1.8
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: op.h,v 1.7 2020/12/28 19:38:54 rillig Exp $ */ | 1 | /* $NetBSD: op.h,v 1.8 2021/01/02 01:06:15 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. | |
@@ -21,41 +21,43 @@ | @@ -21,41 +21,43 @@ | |||
21 | * | 21 | * | |
22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
23 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 23 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
24 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | 24 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
25 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | 25 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
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 | #include <stdbool.h> | |||
35 | ||||
34 | /* | 36 | /* | |
35 | * Various information about operators | 37 | * Various information about operators | |
36 | */ | 38 | */ | |
37 | typedef struct { | 39 | typedef struct { | |
38 | u_int m_binary : 1; /* binary operator */ | 40 | bool m_binary : 1; /* binary operator */ | |
39 | u_int m_logical : 1; /* logical operator, result is int */ | 41 | bool m_logical : 1; /* logical operator, result is int */ | |
40 | u_int m_requires_integer : 1; | 42 | bool m_requires_integer : 1; | |
41 | u_int m_requires_scalar : 1; | 43 | bool m_requires_scalar : 1; | |
42 | u_int m_requires_arith : 1; | 44 | bool m_requires_arith : 1; | |
43 | u_int m_fold : 1; /* operands should be folded */ | 45 | bool m_fold : 1; /* operands should be folded */ | |
44 | u_int m_vctx : 1; /* value context for left operand */ | 46 | bool m_vctx : 1; /* value context for left operand */ | |
45 | u_int m_tctx : 1; /* test context for left operand */ | 47 | bool m_tctx : 1; /* test context for left operand */ | |
46 | u_int m_balance : 1; /* operator requires balancing */ | 48 | bool m_balance : 1; /* operator requires balancing */ | |
47 | u_int m_sideeff : 1; /* operator has side effect */ | 49 | bool m_sideeff : 1; /* operator has side effect */ | |
48 | u_int m_tlansiu : 1; /* warn if left op. is unsign. in ANSI C */ | 50 | bool m_tlansiu : 1; /* warn if left op. is unsign. in ANSI C */ | |
49 | u_int m_transiu : 1; /* warn if right op. is unsign. in ANSI C */ | 51 | bool m_transiu : 1; /* warn if right op. is unsign. in ANSI C */ | |
50 | u_int m_tpconf : 1; /* test possible precedence confusion */ | 52 | bool m_tpconf : 1; /* test possible precedence confusion */ | |
51 | u_int m_comp : 1; /* operator performs comparison */ | 53 | bool m_comp : 1; /* operator performs comparison */ | |
52 | u_int m_valid_on_enum : 1; /* valid operation on enums */ | 54 | bool m_valid_on_enum : 1; /* valid operation on enums */ | |
53 | u_int m_bad_on_enum : 1; /* dubious operation on enums */ | 55 | bool m_bad_on_enum : 1; /* dubious operation on enums */ | |
54 | u_int m_eqwarn : 1; /* warning if on operand stems from == */ | 56 | bool m_eqwarn : 1; /* warning if on operand stems from == */ | |
55 | u_int m_requires_integer_or_complex : 1; | 57 | bool m_requires_integer_or_complex : 1; | |
56 | const char *m_name; /* name of op. */ | 58 | const char *m_name; /* name of op. */ | |
57 | } mod_t; | 59 | } mod_t; | |
58 | 60 | |||
59 | extern mod_t modtab[]; | 61 | extern mod_t modtab[]; | |
60 | 62 | |||
61 | #include "ops.h" | 63 | #include "ops.h" |
--- src/usr.bin/xlint/lint1/scan.l 2021/01/01 11:51:15 1.109
+++ src/usr.bin/xlint/lint1/scan.l 2021/01/02 01:06:15 1.110
@@ -1,15 +1,15 @@ | @@ -1,15 +1,15 @@ | |||
1 | %{ | 1 | %{ | |
2 | /* $NetBSD: scan.l,v 1.109 2021/01/01 11:51:15 rillig Exp $ */ | 2 | /* $NetBSD: scan.l,v 1.110 2021/01/02 01:06:15 rillig Exp $ */ | |
3 | 3 | |||
4 | /* | 4 | /* | |
5 | * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. | 5 | * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. | |
6 | * Copyright (c) 1994, 1995 Jochen Pohl | 6 | * Copyright (c) 1994, 1995 Jochen Pohl | |
7 | * All Rights Reserved. | 7 | * All Rights Reserved. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
15 | * notice, this list of conditions and the following disclaimer in the | 15 | * notice, this list of conditions and the following disclaimer in the | |
@@ -25,27 +25,27 @@ | @@ -25,27 +25,27 @@ | |||
25 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 25 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
26 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | 26 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
27 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | 27 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | 28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
29 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 29 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
30 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 30 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
31 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 31 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
32 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 32 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
33 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 33 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
34 | */ | 34 | */ | |
35 | 35 | |||
36 | #include <sys/cdefs.h> | 36 | #include <sys/cdefs.h> | |
37 | #if defined(__RCSID) && !defined(lint) | 37 | #if defined(__RCSID) && !defined(lint) | |
38 | __RCSID("$NetBSD: scan.l,v 1.109 2021/01/01 11:51:15 rillig Exp $"); | 38 | __RCSID("$NetBSD: scan.l,v 1.110 2021/01/02 01:06:15 rillig Exp $"); | |
39 | #endif | 39 | #endif | |
40 | 40 | |||
41 | #include <ctype.h> | 41 | #include <ctype.h> | |
42 | #include <errno.h> | 42 | #include <errno.h> | |
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 <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 | #include "cgram.h" | 50 | #include "cgram.h" | |
51 | 51 | |||
@@ -189,30 +189,30 @@ badchar(int c) | @@ -189,30 +189,30 @@ badchar(int c) | |||
189 | error(250, c); | 189 | error(250, c); | |
190 | } | 190 | } | |
191 | 191 | |||
192 | /* | 192 | /* | |
193 | * Keywords. | 193 | * Keywords. | |
194 | * During initialisation they are written to the symbol table. | 194 | * During initialisation they are written to the symbol table. | |
195 | */ | 195 | */ | |
196 | static struct kwtab { | 196 | static struct kwtab { | |
197 | const char *kw_name; /* keyword */ | 197 | const char *kw_name; /* keyword */ | |
198 | int kw_token; /* token returned by yylex() */ | 198 | int kw_token; /* token returned by yylex() */ | |
199 | scl_t kw_scl; /* storage class if kw_token T_SCLASS */ | 199 | scl_t kw_scl; /* storage class if kw_token T_SCLASS */ | |
200 | tspec_t kw_tspec; /* type spec. if kw_token T_TYPE or T_SOU */ | 200 | tspec_t kw_tspec; /* type spec. if kw_token T_TYPE or T_SOU */ | |
201 | tqual_t kw_tqual; /* type qual. fi kw_token T_QUAL */ | 201 | tqual_t kw_tqual; /* type qual. fi kw_token T_QUAL */ | |
202 | u_int kw_c89 : 1; /* c89 keyword */ | 202 | bool kw_c89 : 1; /* C89 keyword */ | |
203 | u_int kw_c99 : 1; /* c99 keyword */ | 203 | bool kw_c99 : 1; /* C99 keyword */ | |
204 | u_int kw_gcc : 1; /* GCC keyword */ | 204 | bool kw_gcc : 1; /* GCC keyword */ | |
205 | u_int kw_attr : 1; /* GCC attribute, keyword */ | 205 | bool kw_attr : 1; /* GCC attribute, keyword */ | |
206 | u_int kw_deco : 3; /* 1 = name, 2 = __name, 4 = __name__ */ | 206 | u_int kw_deco : 3; /* 1 = name, 2 = __name, 4 = __name__ */ | |
207 | } kwtab[] = { | 207 | } kwtab[] = { | |
208 | #ifdef INT128_SIZE | 208 | #ifdef INT128_SIZE | |
209 | { "__int128_t", T_TYPE, 0, INT128, 0, 0,1,0,0,1 }, | 209 | { "__int128_t", T_TYPE, 0, INT128, 0, 0,1,0,0,1 }, | |
210 | { "__uint128_t",T_TYPE, 0, UINT128,0, 0,1,0,0,1 }, | 210 | { "__uint128_t",T_TYPE, 0, UINT128,0, 0,1,0,0,1 }, | |
211 | #endif | 211 | #endif | |
212 | { "__thread", T_QUAL, 0, 0, THREAD, 0,0,1,0,1 }, | 212 | { "__thread", T_QUAL, 0, 0, THREAD, 0,0,1,0,1 }, | |
213 | { "_Alignof", T_ALIGNOF, 0, 0, 0, 0,0,0,0,1 }, | 213 | { "_Alignof", T_ALIGNOF, 0, 0, 0, 0,0,0,0,1 }, | |
214 | { "_Bool", T_TYPE, 0, BOOL, 0, 0,1,0,0,1 }, | 214 | { "_Bool", T_TYPE, 0, BOOL, 0, 0,1,0,0,1 }, | |
215 | { "_Complex", T_TYPE, 0, COMPLEX,0, 0,1,0,0,1 }, | 215 | { "_Complex", T_TYPE, 0, COMPLEX,0, 0,1,0,0,1 }, | |
216 | { "_Generic", T_GENERIC, 0, 0, 0, 0,1,0,0,1 }, | 216 | { "_Generic", T_GENERIC, 0, 0, 0, 0,1,0,0,1 }, | |
217 | { "_Noreturn", T_NORETURN, 0, 0, 0, 0,1,0,0,1 }, | 217 | { "_Noreturn", T_NORETURN, 0, 0, 0, 0,1,0,0,1 }, | |
218 | { "_Thread_local",T_QUAL, 0, 0, THREAD, 0,1,0,0,1 }, | 218 | { "_Thread_local",T_QUAL, 0, 0, THREAD, 0,1,0,0,1 }, |
--- src/usr.bin/xlint/lint2/lint2.h 2020/12/30 10:46:11 1.11
+++ src/usr.bin/xlint/lint2/lint2.h 2021/01/02 01:06:15 1.12
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: lint2.h,v 1.11 2020/12/30 10:46:11 rillig Exp $ */ | 1 | /* $NetBSD: lint2.h,v 1.12 2021/01/02 01:06:15 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 | |
@@ -29,34 +29,34 @@ | @@ -29,34 +29,34 @@ | |||
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 | #include "lint.h" | 35 | #include "lint.h" | |
36 | 36 | |||
37 | /* | 37 | /* | |
38 | * Types are described by structures of type type_t. | 38 | * Types are described by structures of type type_t. | |
39 | */ | 39 | */ | |
40 | struct type { | 40 | struct type { | |
41 | tspec_t t_tspec; /* type specifier */ | 41 | tspec_t t_tspec; /* type specifier */ | |
42 | u_int t_const : 1; /* constant */ | 42 | bool t_const : 1; /* constant */ | |
43 | u_int t_volatile : 1; /* volatile */ | 43 | bool t_volatile : 1; /* volatile */ | |
44 | u_int t_vararg : 1; /* function has variable number of arguments */ | 44 | bool t_vararg : 1; /* function has variable number of arguments */ | |
45 | u_int t_isenum : 1; /* enum type */ | 45 | bool t_isenum : 1; /* enum type */ | |
46 | u_int t_proto : 1; /* this is a prototype */ | 46 | bool t_proto : 1; /* this is a prototype */ | |
47 | u_int t_istag : 1; /* tag with _t_tag valid */ | 47 | bool t_istag : 1; /* tag with _t_tag valid */ | |
48 | u_int t_istynam : 1; /* tag with _t_tynam valid */ | 48 | bool t_istynam : 1; /* tag with _t_tynam valid */ | |
49 | u_int t_isuniqpos : 1; /* tag with _t_uniqpos valid */ | 49 | bool t_isuniqpos : 1; /* tag with _t_uniqpos valid */ | |
50 | union { | 50 | union { | |
51 | int _t_dim; /* if the type is an ARRAY than this | 51 | int _t_dim; /* if the type is an ARRAY than this | |
52 | is the dimension of the array. */ | 52 | is the dimension of the array. */ | |
53 | struct hte *_t_tag; /* hash table entry of tag if | 53 | struct hte *_t_tag; /* hash table entry of tag if | |
54 | t_isenum, STRUCT or UNION */ | 54 | t_isenum, STRUCT or UNION */ | |
55 | struct hte *_t_tynam; /* hash table entry of typename if | 55 | struct hte *_t_tynam; /* hash table entry of typename if | |
56 | t_isenum, STRUCT or UNION */ | 56 | t_isenum, STRUCT or UNION */ | |
57 | struct { | 57 | struct { | |
58 | int p_line; | 58 | int p_line; | |
59 | short p_file; | 59 | short p_file; | |
60 | int p_uniq; | 60 | int p_uniq; | |
61 | } _t_uniqpos; /* unique position, for untagged | 61 | } _t_uniqpos; /* unique position, for untagged | |
62 | untyped STRUCTs, UNIONS, and ENUMs, | 62 | untyped STRUCTs, UNIONS, and ENUMs, | |
@@ -72,30 +72,30 @@ struct type { | @@ -72,30 +72,30 @@ struct type { | |||
72 | #define t_tag t_u._t_tag | 72 | #define t_tag t_u._t_tag | |
73 | #define t_tynam t_u._t_tynam | 73 | #define t_tynam t_u._t_tynam | |
74 | #define t_uniqpos t_u._t_uniqpos | 74 | #define t_uniqpos t_u._t_uniqpos | |
75 | #define t_args t_u._t_args | 75 | #define t_args t_u._t_args | |
76 | 76 | |||
77 | /* | 77 | /* | |
78 | * argument information | 78 | * argument information | |
79 | * | 79 | * | |
80 | * Such a structure is created for each argument of a function call | 80 | * Such a structure is created for each argument of a function call | |
81 | * which is an integer constant or a constant string. | 81 | * which is an integer constant or a constant string. | |
82 | */ | 82 | */ | |
83 | typedef struct arginf { | 83 | typedef struct arginf { | |
84 | int a_num; /* # of argument (1..) */ | 84 | int a_num; /* # of argument (1..) */ | |
85 | u_int a_zero : 1; /* argument is 0 */ | 85 | bool a_zero : 1; /* argument is 0 */ | |
86 | u_int a_pcon : 1; /* msb of argument is not set */ | 86 | bool a_pcon : 1; /* msb of argument is not set */ | |
87 | u_int a_ncon : 1; /* msb of argument is set */ | 87 | bool a_ncon : 1; /* msb of argument is set */ | |
88 | u_int a_fmt : 1; /* a_fstrg points to format string */ | 88 | bool a_fmt : 1; /* a_fstrg points to format string */ | |
89 | char *a_fstrg; /* format string */ | 89 | char *a_fstrg; /* format string */ | |
90 | struct arginf *a_next; /* information for next const. argument */ | 90 | struct arginf *a_next; /* information for next const. argument */ | |
91 | } arginf_t; | 91 | } arginf_t; | |
92 | 92 | |||
93 | /* | 93 | /* | |
94 | * Keeps information about position in source file. | 94 | * Keeps information about position in source file. | |
95 | */ | 95 | */ | |
96 | typedef struct { | 96 | typedef struct { | |
97 | u_short p_src; /* index of name of translation unit | 97 | u_short p_src; /* index of name of translation unit | |
98 | (the name which was specified at the | 98 | (the name which was specified at the | |
99 | command line) */ | 99 | command line) */ | |
100 | u_short p_line; /* line number in p_src */ | 100 | u_short p_line; /* line number in p_src */ | |
101 | u_short p_isrc; /* index of (included) file */ | 101 | u_short p_isrc; /* index of (included) file */ | |
@@ -108,82 +108,82 @@ typedef struct { | @@ -108,82 +108,82 @@ typedef struct { | |||
108 | * To save memory, variable sized structures are used. If | 108 | * To save memory, variable sized structures are used. If | |
109 | * all s_va, s_prfl and s_scfl are not set, the memory allocated | 109 | * all s_va, s_prfl and s_scfl are not set, the memory allocated | |
110 | * for a symbol is only large enough to keep the first member of | 110 | * for a symbol is only large enough to keep the first member of | |
111 | * struct sym, s_s. | 111 | * struct sym, s_s. | |
112 | */ | 112 | */ | |
113 | typedef struct sym { | 113 | typedef struct sym { | |
114 | struct { | 114 | struct { | |
115 | pos_t s_pos; /* pos of def./decl. */ | 115 | pos_t s_pos; /* pos of def./decl. */ | |
116 | #ifndef lint | 116 | #ifndef lint | |
117 | u_int s_def : 3; /* DECL, TDEF or DEF */ | 117 | u_int s_def : 3; /* DECL, TDEF or DEF */ | |
118 | #else | 118 | #else | |
119 | def_t s_def; | 119 | def_t s_def; | |
120 | #endif | 120 | #endif | |
121 | u_int s_rval : 1; /* function has return value */ | 121 | bool s_rval : 1; /* function has return value */ | |
122 | u_int s_inline : 1; /* function is inline */ | 122 | bool s_inline : 1; /* function is inline */ | |
123 | u_int s_osdef : 1; /* old style function definition */ | 123 | bool s_osdef : 1; /* old style function definition */ | |
124 | u_int s_static : 1; /* symbol is static */ | 124 | bool s_static : 1; /* symbol is static */ | |
125 | u_int s_va : 1; /* check only first s_nva arguments */ | 125 | bool s_va : 1; /* check only first s_nva arguments */ | |
126 | u_int s_prfl : 1; /* printflike */ | 126 | bool s_prfl : 1; /* printflike */ | |
127 | u_int s_scfl : 1; /* scanflike */ | 127 | bool s_scfl : 1; /* scanflike */ | |
128 | u_short s_type; /* type */ | 128 | u_short s_type; /* type */ | |
129 | struct sym *s_next; /* next symbol with same name */ | 129 | struct sym *s_next; /* next symbol with same name */ | |
130 | } s_s; | 130 | } s_s; | |
131 | short s_nva; | 131 | short s_nva; | |
132 | short s_nprfl; | 132 | short s_nprfl; | |
133 | short s_nscfl; | 133 | short s_nscfl; | |
134 | } sym_t; | 134 | } sym_t; | |
135 | 135 | |||
136 | #define s_pos s_s.s_pos | 136 | #define s_pos s_s.s_pos | |
137 | #define s_rval s_s.s_rval | 137 | #define s_rval s_s.s_rval | |
138 | #define s_osdef s_s.s_osdef | 138 | #define s_osdef s_s.s_osdef | |
139 | #define s_inline s_s.s_inline | 139 | #define s_inline s_s.s_inline | |
140 | #define s_static s_s.s_static | 140 | #define s_static s_s.s_static | |
141 | #define s_def s_s.s_def | 141 | #define s_def s_s.s_def | |
142 | #define s_va s_s.s_va | 142 | #define s_va s_s.s_va | |
143 | #define s_prfl s_s.s_prfl | 143 | #define s_prfl s_s.s_prfl | |
144 | #define s_scfl s_s.s_scfl | 144 | #define s_scfl s_s.s_scfl | |
145 | #define s_type s_s.s_type | 145 | #define s_type s_s.s_type | |
146 | #define s_next s_s.s_next | 146 | #define s_next s_s.s_next | |
147 | 147 | |||
148 | /* | 148 | /* | |
149 | * Used to store information about function calls. | 149 | * Used to store information about function calls. | |
150 | */ | 150 | */ | |
151 | typedef struct fcall { | 151 | typedef struct fcall { | |
152 | pos_t f_pos; /* position of call */ | 152 | pos_t f_pos; /* position of call */ | |
153 | u_int f_rused : 1; /* return value used */ | 153 | bool f_rused : 1; /* return value used */ | |
154 | u_int f_rdisc : 1; /* return value discarded (casted to void) */ | 154 | bool f_rdisc : 1; /* return value discarded (casted to void) */ | |
155 | u_short f_type; /* types of expected return value and args */ | 155 | u_short f_type; /* types of expected return value and args */ | |
156 | arginf_t *f_args; /* information about constant arguments */ | 156 | arginf_t *f_args; /* information about constant arguments */ | |
157 | struct fcall *f_next; /* next call of same function */ | 157 | struct fcall *f_next; /* next call of same function */ | |
158 | } fcall_t; | 158 | } fcall_t; | |
159 | 159 | |||
160 | /* | 160 | /* | |
161 | * Used to store information about usage of symbols other | 161 | * Used to store information about usage of symbols other | |
162 | * than for function calls. | 162 | * than for function calls. | |
163 | */ | 163 | */ | |
164 | typedef struct usym { | 164 | typedef struct usym { | |
165 | pos_t u_pos; /* position */ | 165 | pos_t u_pos; /* position */ | |
166 | struct usym *u_next; /* next usage */ | 166 | struct usym *u_next; /* next usage */ | |
167 | } usym_t; | 167 | } usym_t; | |
168 | 168 | |||
169 | /* | 169 | /* | |
170 | * hash table entry | 170 | * hash table entry | |
171 | */ | 171 | */ | |
172 | typedef struct hte { | 172 | typedef struct hte { | |
173 | const char *h_name; /* name */ | 173 | const char *h_name; /* name */ | |
174 | u_int h_used : 1; /* symbol is used */ | 174 | bool h_used : 1; /* symbol is used */ | |
175 | u_int h_def : 1; /* symbol is defined */ | 175 | bool h_def : 1; /* symbol is defined */ | |
176 | u_int h_static : 1; /* static symbol */ | 176 | bool h_static : 1; /* static symbol */ | |
177 | sym_t *h_syms; /* declarations and definitions */ | 177 | sym_t *h_syms; /* declarations and definitions */ | |
178 | sym_t **h_lsym; /* points to s_next of last decl./def. */ | 178 | sym_t **h_lsym; /* points to s_next of last decl./def. */ | |
179 | fcall_t *h_calls; /* function calls */ | 179 | fcall_t *h_calls; /* function calls */ | |
180 | fcall_t **h_lcall; /* points to f_next of last call */ | 180 | fcall_t **h_lcall; /* points to f_next of last call */ | |
181 | usym_t *h_usyms; /* usage info */ | 181 | usym_t *h_usyms; /* usage info */ | |
182 | usym_t **h_lusym; /* points to u_next of last usage info */ | 182 | usym_t **h_lusym; /* points to u_next of last usage info */ | |
183 | struct hte *h_link; /* next hte with same hash function */ | 183 | struct hte *h_link; /* next hte with same hash function */ | |
184 | struct hte *h_hte; /* pointer to other htes (for renames */ | 184 | struct hte *h_hte; /* pointer to other htes (for renames */ | |
185 | } hte_t; | 185 | } hte_t; | |
186 | 186 | |||
187 | /* maps type indices into pointers to type structs */ | 187 | /* maps type indices into pointers to type structs */ | |
188 | #define TP(idx) (tlst[idx]) | 188 | #define TP(idx) (tlst[idx]) | |
189 | 189 |