understand __attribute__((__packed__)) and __packed.diff -r1.44 -r1.45 src/usr.bin/xlint/lint1/cgram.y
(christos)
--- src/usr.bin/xlint/lint1/cgram.y 2009/05/02 16:10:49 1.44
+++ src/usr.bin/xlint/lint1/cgram.y 2009/10/02 15:03:45 1.45
@@ -1,15 +1,15 @@ | @@ -1,15 +1,15 @@ | |||
1 | %{ | 1 | %{ | |
2 | /* $NetBSD: cgram.y,v 1.44 2009/05/02 16:10:49 christos Exp $ */ | 2 | /* $NetBSD: cgram.y,v 1.45 2009/10/02 15:03:45 christos 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: cgram.y,v 1.44 2009/05/02 16:10:49 christos Exp $"); | 38 | __RCSID("$NetBSD: cgram.y,v 1.45 2009/10/02 15:03:45 christos Exp $"); | |
39 | #endif | 39 | #endif | |
40 | 40 | |||
41 | #include <stdlib.h> | 41 | #include <stdlib.h> | |
42 | #include <string.h> | 42 | #include <string.h> | |
43 | #include <limits.h> | 43 | #include <limits.h> | |
44 | 44 | |||
45 | #include "lint1.h" | 45 | #include "lint1.h" | |
46 | 46 | |||
47 | extern char *yytext; | 47 | extern char *yytext; | |
48 | /* | 48 | /* | |
49 | * Contains the level of current declaration. 0 is extern. | 49 | * Contains the level of current declaration. 0 is extern. | |
50 | * Used for symbol table entries. | 50 | * Used for symbol table entries. | |
51 | */ | 51 | */ | |
@@ -172,26 +172,38 @@ static inline void RESTORE(const char *f | @@ -172,26 +172,38 @@ static inline void RESTORE(const char *f | |||
172 | %token T_DEFAULT | 172 | %token T_DEFAULT | |
173 | %token T_IF | 173 | %token T_IF | |
174 | %token T_ELSE | 174 | %token T_ELSE | |
175 | %token T_SWITCH | 175 | %token T_SWITCH | |
176 | %token T_DO | 176 | %token T_DO | |
177 | %token T_WHILE | 177 | %token T_WHILE | |
178 | %token T_FOR | 178 | %token T_FOR | |
179 | %token T_GOTO | 179 | %token T_GOTO | |
180 | %token T_CONTINUE | 180 | %token T_CONTINUE | |
181 | %token T_BREAK | 181 | %token T_BREAK | |
182 | %token T_RETURN | 182 | %token T_RETURN | |
183 | %token T_ASM | 183 | %token T_ASM | |
184 | %token T_SYMBOLRENAME | 184 | %token T_SYMBOLRENAME | |
185 | %token T_PACKED | |||
186 | /* Type Attributes */ | |||
187 | %token <y_type> T_ATTRIBUTE | |||
188 | %token <y_type> T_AT_ALIGNED | |||
189 | %token <y_type> T_AT_DEPRECATED | |||
190 | %token <y_type> T_AT_MAY_ALIAS | |||
191 | %token <y_type> T_AT_PACKED | |||
192 | %token <y_type> T_AT_TUINION | |||
193 | %token <y_type> T_AT_TUNION | |||
194 | %token <y_type> T_AT_UNUSED | |||
195 | ||||
196 | ||||
185 | 197 | |||
186 | %left T_COMMA | 198 | %left T_COMMA | |
187 | %right T_ASSIGN T_OPASS | 199 | %right T_ASSIGN T_OPASS | |
188 | %right T_QUEST T_COLON | 200 | %right T_QUEST T_COLON | |
189 | %left T_LOGOR | 201 | %left T_LOGOR | |
190 | %left T_LOGAND | 202 | %left T_LOGAND | |
191 | %left T_OR | 203 | %left T_OR | |
192 | %left T_XOR | 204 | %left T_XOR | |
193 | %left T_AND | 205 | %left T_AND | |
194 | %left T_EQOP | 206 | %left T_EQOP | |
195 | %left T_RELOP | 207 | %left T_RELOP | |
196 | %left T_SHFTOP | 208 | %left T_SHFTOP | |
197 | %left T_ADDOP | 209 | %left T_ADDOP | |
@@ -202,26 +214,28 @@ static inline void RESTORE(const char *f | @@ -202,26 +214,28 @@ static inline void RESTORE(const char *f | |||
202 | %token <y_sb> T_NAME | 214 | %token <y_sb> T_NAME | |
203 | %token <y_sb> T_TYPENAME | 215 | %token <y_sb> T_TYPENAME | |
204 | %token <y_val> T_CON | 216 | %token <y_val> T_CON | |
205 | %token <y_strg> T_STRING | 217 | %token <y_strg> T_STRING | |
206 | 218 | |||
207 | %type <y_sym> func_decl | 219 | %type <y_sym> func_decl | |
208 | %type <y_sym> notype_decl | 220 | %type <y_sym> notype_decl | |
209 | %type <y_sym> type_decl | 221 | %type <y_sym> type_decl | |
210 | %type <y_type> typespec | 222 | %type <y_type> typespec | |
211 | %type <y_type> clrtyp_typespec | 223 | %type <y_type> clrtyp_typespec | |
212 | %type <y_type> notype_typespec | 224 | %type <y_type> notype_typespec | |
213 | %type <y_type> struct_spec | 225 | %type <y_type> struct_spec | |
214 | %type <y_type> enum_spec | 226 | %type <y_type> enum_spec | |
227 | %type <y_type> type_attribute | |||
228 | %type <y_type> type_attribute_spec | |||
215 | %type <y_sym> struct_tag | 229 | %type <y_sym> struct_tag | |
216 | %type <y_sym> enum_tag | 230 | %type <y_sym> enum_tag | |
217 | %type <y_tspec> struct | 231 | %type <y_tspec> struct | |
218 | %type <y_sym> struct_declaration | 232 | %type <y_sym> struct_declaration | |
219 | %type <y_sb> identifier | 233 | %type <y_sb> identifier | |
220 | %type <y_sym> member_declaration_list_with_rbrace | 234 | %type <y_sym> member_declaration_list_with_rbrace | |
221 | %type <y_sym> member_declaration_list | 235 | %type <y_sym> member_declaration_list | |
222 | %type <y_sym> member_declaration | 236 | %type <y_sym> member_declaration | |
223 | %type <y_sym> notype_member_decls | 237 | %type <y_sym> notype_member_decls | |
224 | %type <y_sym> type_member_decls | 238 | %type <y_sym> type_member_decls | |
225 | %type <y_sym> notype_member_decl | 239 | %type <y_sym> notype_member_decl | |
226 | %type <y_sym> type_member_decl | 240 | %type <y_sym> type_member_decl | |
227 | %type <y_tnode> constant | 241 | %type <y_tnode> constant | |
@@ -444,45 +458,64 @@ declaration: | @@ -444,45 +458,64 @@ declaration: | |||
444 | | declspecs deftyp T_SEMI { | 458 | | declspecs deftyp T_SEMI { | |
445 | if (dcs->d_scl == TYPEDEF) { | 459 | if (dcs->d_scl == TYPEDEF) { | |
446 | /* typedef declares no type name */ | 460 | /* typedef declares no type name */ | |
447 | warning(72); | 461 | warning(72); | |
448 | } else if (!dcs->d_nedecl) { | 462 | } else if (!dcs->d_nedecl) { | |
449 | /* empty declaration */ | 463 | /* empty declaration */ | |
450 | warning(2); | 464 | warning(2); | |
451 | } | 465 | } | |
452 | } | 466 | } | |
453 | | declspecs deftyp type_init_decls T_SEMI | 467 | | declspecs deftyp type_init_decls T_SEMI | |
454 | | error T_SEMI | 468 | | error T_SEMI | |
455 | ; | 469 | ; | |
456 | 470 | |||
471 | type_attribute_spec: | |||
472 | T_AT_DEPRECATED | |||
473 | | T_AT_ALIGNED T_LPARN constant T_RPARN | |||
474 | | T_AT_MAY_ALIAS | |||
475 | | T_AT_PACKED { | |||
476 | addpacked(); | |||
477 | } | |||
478 | | T_AT_TUNION | |||
479 | | T_AT_UNUSED | |||
480 | ; | |||
481 | ||||
482 | type_attribute: | |||
483 | T_ATTRIBUTE T_LPARN T_LPARN type_attribute_spec T_RPARN T_RPARN | |||
484 | | T_PACKED { | |||
485 | addpacked(); | |||
486 | } | |||
487 | ; | |||
488 | ||||
457 | clrtyp: | 489 | clrtyp: | |
458 | { | 490 | { | |
459 | clrtyp(); | 491 | clrtyp(); | |
460 | } | 492 | } | |
461 | ; | 493 | ; | |
462 | 494 | |||
463 | deftyp: | 495 | deftyp: | |
464 | /* empty */ { | 496 | /* empty */ { | |
465 | deftyp(); | 497 | deftyp(); | |
466 | } | 498 | } | |
467 | ; | 499 | ; | |
468 | 500 | |||
469 | declspecs: | 501 | declspecs: | |
470 | clrtyp_typespec { | 502 | clrtyp_typespec { | |
471 | addtype($1); | 503 | addtype($1); | |
472 | } | 504 | } | |
473 | | declmods typespec { | 505 | | declmods typespec { | |
474 | addtype($2); | 506 | addtype($2); | |
475 | } | 507 | } | |
508 | | declspecs type_attribute | |||
476 | | declspecs declmod | 509 | | declspecs declmod | |
477 | | declspecs notype_typespec { | 510 | | declspecs notype_typespec { | |
478 | addtype($2); | 511 | addtype($2); | |
479 | } | 512 | } | |
480 | ; | 513 | ; | |
481 | 514 | |||
482 | declmods: | 515 | declmods: | |
483 | clrtyp T_QUAL { | 516 | clrtyp T_QUAL { | |
484 | addqual($2); | 517 | addqual($2); | |
485 | } | 518 | } | |
486 | | clrtyp T_SCLASS { | 519 | | clrtyp T_SCLASS { | |
487 | addscl($2); | 520 | addscl($2); | |
488 | } | 521 | } |
--- src/usr.bin/xlint/lint1/scan.l 2009/05/02 16:10:49 1.44
+++ src/usr.bin/xlint/lint1/scan.l 2009/10/02 15:03:45 1.45
@@ -1,15 +1,15 @@ | @@ -1,15 +1,15 @@ | |||
1 | %{ | 1 | %{ | |
2 | /* $NetBSD: scan.l,v 1.44 2009/05/02 16:10:49 christos Exp $ */ | 2 | /* $NetBSD: scan.l,v 1.45 2009/10/02 15:03:45 christos 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.44 2009/05/02 16:10:49 christos Exp $"); | 38 | __RCSID("$NetBSD: scan.l,v 1.45 2009/10/02 15:03:45 christos Exp $"); | |
39 | #endif | 39 | #endif | |
40 | 40 | |||
41 | #include <stdlib.h> | 41 | #include <stdlib.h> | |
42 | #include <string.h> | 42 | #include <string.h> | |
43 | #include <limits.h> | 43 | #include <limits.h> | |
44 | #include <float.h> | 44 | #include <float.h> | |
45 | #include <ctype.h> | 45 | #include <ctype.h> | |
46 | #include <errno.h> | 46 | #include <errno.h> | |
47 | #include <math.h> | 47 | #include <math.h> | |
48 | 48 | |||
49 | #include "lint1.h" | 49 | #include "lint1.h" | |
50 | #include "cgram.h" | 50 | #include "cgram.h" | |
51 | 51 | |||
@@ -183,27 +183,41 @@ badchar(int c) | @@ -183,27 +183,41 @@ badchar(int c) | |||
183 | * Keywords. | 183 | * Keywords. | |
184 | * During initialisation they are written to the symbol table. | 184 | * During initialisation they are written to the symbol table. | |
185 | */ | 185 | */ | |
186 | static struct kwtab { | 186 | static struct kwtab { | |
187 | const char *kw_name; /* keyword */ | 187 | const char *kw_name; /* keyword */ | |
188 | int kw_token; /* token returned by yylex() */ | 188 | int kw_token; /* token returned by yylex() */ | |
189 | scl_t kw_scl; /* storage class if kw_token T_SCLASS */ | 189 | scl_t kw_scl; /* storage class if kw_token T_SCLASS */ | |
190 | tspec_t kw_tspec; /* type spec. if kw_token T_TYPE or T_SOU */ | 190 | tspec_t kw_tspec; /* type spec. if kw_token T_TYPE or T_SOU */ | |
191 | tqual_t kw_tqual; /* type qual. fi kw_token T_QUAL */ | 191 | tqual_t kw_tqual; /* type qual. fi kw_token T_QUAL */ | |
192 | u_int kw_c89; /* c89 keyword */ | 192 | u_int kw_c89; /* c89 keyword */ | |
193 | u_int kw_c99; /* c99 keyword */ | 193 | u_int kw_c99; /* c99 keyword */ | |
194 | u_int kw_gcc; /* GCC keyword */ | 194 | u_int kw_gcc; /* GCC keyword */ | |
195 | } kwtab[] = { | 195 | } kwtab[] = { | |
196 | { "__alignof__",T_ALIGNOF, 0, 0, 0, 0, 0, 0 }, | 196 | { "__alignof__", T_ALIGNOF, 0, 0, 0, 0, 0, 0 }, | |
197 | { "__attribute__",T_ATTRIBUTE, 0, 0, 0, 0, 0, 1 }, | |||
198 | { "attribute", T_ATTRIBUTE, 0, 0, 0, 0, 0, 1 }, | |||
199 | { "__packed__", T_AT_PACKED, 0, 0, 0, 0, 0, 1 }, | |||
200 | { "packed", T_AT_PACKED, 0, 0, 0, 0, 0, 1 }, | |||
201 | { "__aligned__",T_AT_ALIGNED, 0, 0, 0, 0, 0, 1 }, | |||
202 | { "aligned", T_AT_ALIGNED, 0, 0, 0, 0, 0, 1 }, | |||
203 | { "__transparent_union__",T_AT_TUNION,0,0, 0, 0, 0, 1 }, | |||
204 | { "transparent_union",T_AT_TUNION,0, 0, 0, 0, 0, 1 }, | |||
205 | { "__unused__", T_AT_UNUSED, 0, 0, 0, 0, 0, 1 }, | |||
206 | { "unused", T_AT_UNUSED, 0, 0, 0, 0, 0, 1 }, | |||
207 | { "__deprecated__",T_AT_DEPRECATED,0, 0, 0, 0, 0, 1 }, | |||
208 | { "deprecated", T_AT_DEPRECATED,0, 0, 0, 0, 0, 1 }, | |||
209 | { "__may_alias__",T_AT_MAY_ALIAS,0, 0, 0, 0, 0, 1 }, | |||
210 | { "may_alias", T_AT_MAY_ALIAS, 0, 0, 0, 0, 0, 1 }, | |||
197 | { "asm", T_ASM, 0, 0, 0, 0, 0, 1 }, | 211 | { "asm", T_ASM, 0, 0, 0, 0, 0, 1 }, | |
198 | { "__asm", T_ASM, 0, 0, 0, 0, 0, 0 }, | 212 | { "__asm", T_ASM, 0, 0, 0, 0, 0, 0 }, | |
199 | { "__asm__", T_ASM, 0, 0, 0, 0, 0, 0 }, | 213 | { "__asm__", T_ASM, 0, 0, 0, 0, 0, 0 }, | |
200 | { "auto", T_SCLASS, AUTO, 0, 0, 0, 0, 0 }, | 214 | { "auto", T_SCLASS, AUTO, 0, 0, 0, 0, 0 }, | |
201 | { "break", T_BREAK, 0, 0, 0, 0, 0, 0 }, | 215 | { "break", T_BREAK, 0, 0, 0, 0, 0, 0 }, | |
202 | { "_Bool", T_TYPE, 0, BOOL, 0, 0, 1, 0 }, | 216 | { "_Bool", T_TYPE, 0, BOOL, 0, 0, 1, 0 }, | |
203 | { "case", T_CASE, 0, 0, 0, 0, 0, 0 }, | 217 | { "case", T_CASE, 0, 0, 0, 0, 0, 0 }, | |
204 | { "char", T_TYPE, 0, CHAR, 0, 0, 0, 0 }, | 218 | { "char", T_TYPE, 0, CHAR, 0, 0, 0, 0 }, | |
205 | { "const", T_QUAL, 0, 0, CONST, 1, 0, 0 }, | 219 | { "const", T_QUAL, 0, 0, CONST, 1, 0, 0 }, | |
206 | { "_Complex", T_TYPE, 0, COMPLEX,0, 0, 1, 0 }, | 220 | { "_Complex", T_TYPE, 0, COMPLEX,0, 0, 1, 0 }, | |
207 | { "__const__", T_QUAL, 0, 0, CONST, 0, 0, 0 }, | 221 | { "__const__", T_QUAL, 0, 0, CONST, 0, 0, 0 }, | |
208 | { "__const", T_QUAL, 0, 0, CONST, 0, 0, 0 }, | 222 | { "__const", T_QUAL, 0, 0, CONST, 0, 0, 0 }, | |
209 | { "continue", T_CONTINUE, 0, 0, 0, 0, 0, 0 }, | 223 | { "continue", T_CONTINUE, 0, 0, 0, 0, 0, 0 }, | |
@@ -218,26 +232,27 @@ static struct kwtab { | @@ -218,26 +232,27 @@ static struct kwtab { | |||
218 | { "goto", T_GOTO, 0, 0, 0, 0, 0, 0 }, | 232 | { "goto", T_GOTO, 0, 0, 0, 0, 0, 0 }, | |
219 | { "if", T_IF, 0, 0, 0, 0, 0, 0 }, | 233 | { "if", T_IF, 0, 0, 0, 0, 0, 0 }, | |
220 | { "__imag__", T_IMAG, 0, 0, 0, 0, 1, 0 }, | 234 | { "__imag__", T_IMAG, 0, 0, 0, 0, 1, 0 }, | |
221 | { "inline", T_SCLASS, INLINE, 0, 0, 0, 1, 0 }, | 235 | { "inline", T_SCLASS, INLINE, 0, 0, 0, 1, 0 }, | |
222 | { "__inline__", T_SCLASS, INLINE, 0, 0, 0, 0, 0 }, | 236 | { "__inline__", T_SCLASS, INLINE, 0, 0, 0, 0, 0 }, | |
223 | { "__inline", T_SCLASS, INLINE, 0, 0, 0, 0, 0 }, | 237 | { "__inline", T_SCLASS, INLINE, 0, 0, 0, 0, 0 }, | |
224 | { "int", T_TYPE, 0, INT, 0, 0, 0, 0 }, | 238 | { "int", T_TYPE, 0, INT, 0, 0, 0, 0 }, | |
225 | { "__symbolrename", T_SYMBOLRENAME, 0, 0, 0, 0, 0, 0 }, | 239 | { "__symbolrename", T_SYMBOLRENAME, 0, 0, 0, 0, 0, 0 }, | |
226 | { "long", T_TYPE, 0, LONG, 0, 0, 0, 0 }, | 240 | { "long", T_TYPE, 0, LONG, 0, 0, 0, 0 }, | |
227 | { "__real__", T_REAL, 0, 0, 0, 0, 1, 0 }, | 241 | { "__real__", T_REAL, 0, 0, 0, 0, 1, 0 }, | |
228 | { "register", T_SCLASS, REG, 0, 0, 0, 0, 0 }, | 242 | { "register", T_SCLASS, REG, 0, 0, 0, 0, 0 }, | |
229 | { "restrict", T_QUAL, 0, 0, RESTRICT, 0, 1, 0 }, | 243 | { "restrict", T_QUAL, 0, 0, RESTRICT, 0, 1, 0 }, | |
230 | { "return", T_RETURN, 0, 0, 0, 0, 0, 0 }, | 244 | { "return", T_RETURN, 0, 0, 0, 0, 0, 0 }, | |
245 | { "__packed", T_PACKED, 0, 0, 0, 0, 0, 0 }, | |||
231 | { "short", T_TYPE, 0, SHORT, 0, 0, 0, 0 }, | 246 | { "short", T_TYPE, 0, SHORT, 0, 0, 0, 0 }, | |
232 | { "signed", T_TYPE, 0, SIGNED, 0, 1, 0, 0 }, | 247 | { "signed", T_TYPE, 0, SIGNED, 0, 1, 0, 0 }, | |
233 | { "__signed__", T_TYPE, 0, SIGNED, 0, 0, 0, 0 }, | 248 | { "__signed__", T_TYPE, 0, SIGNED, 0, 0, 0, 0 }, | |
234 | { "__signed", T_TYPE, 0, SIGNED, 0, 0, 0, 0 }, | 249 | { "__signed", T_TYPE, 0, SIGNED, 0, 0, 0, 0 }, | |
235 | { "sizeof", T_SIZEOF, 0, 0, 0, 0, 0, 0 }, | 250 | { "sizeof", T_SIZEOF, 0, 0, 0, 0, 0, 0 }, | |
236 | { "static", T_SCLASS, STATIC, 0, 0, 0, 0, 0 }, | 251 | { "static", T_SCLASS, STATIC, 0, 0, 0, 0, 0 }, | |
237 | { "struct", T_SOU, 0, STRUCT, 0, 0, 0, 0 }, | 252 | { "struct", T_SOU, 0, STRUCT, 0, 0, 0, 0 }, | |
238 | { "switch", T_SWITCH, 0, 0, 0, 0, 0, 0 }, | 253 | { "switch", T_SWITCH, 0, 0, 0, 0, 0, 0 }, | |
239 | { "typedef", T_SCLASS, TYPEDEF, 0, 0, 0, 0, 0 }, | 254 | { "typedef", T_SCLASS, TYPEDEF, 0, 0, 0, 0, 0 }, | |
240 | { "union", T_SOU, 0, UNION, 0, 0, 0, 0 }, | 255 | { "union", T_SOU, 0, UNION, 0, 0, 0, 0 }, | |
241 | { "unsigned", T_TYPE, 0, UNSIGN, 0, 0, 0, 0 }, | 256 | { "unsigned", T_TYPE, 0, UNSIGN, 0, 0, 0, 0 }, | |
242 | { "void", T_TYPE, 0, VOID, 0, 0, 0, 0 }, | 257 | { "void", T_TYPE, 0, VOID, 0, 0, 0, 0 }, | |
243 | { "volatile", T_QUAL, 0, 0, VOLATILE, 1, 0, 0 }, | 258 | { "volatile", T_QUAL, 0, 0, VOLATILE, 1, 0, 0 }, |
--- src/usr.bin/xlint/lint1/decl.c 2009/04/15 01:20:57 1.46
+++ src/usr.bin/xlint/lint1/decl.c 2009/10/02 15:03:45 1.47
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: decl.c,v 1.46 2009/04/15 01:20:57 christos Exp $ */ | 1 | /* $NetBSD: decl.c,v 1.47 2009/10/02 15:03:45 christos 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.46 2009/04/15 01:20:57 christos Exp $"); | 41 | __RCSID("$NetBSD: decl.c,v 1.47 2009/10/02 15:03:45 christos 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; | |
@@ -474,26 +474,61 @@ static void | @@ -474,26 +474,61 @@ static void | |||
474 | settdsym(type_t *tp, sym_t *sym) | 474 | settdsym(type_t *tp, sym_t *sym) | |
475 | { | 475 | { | |
476 | tspec_t t; | 476 | tspec_t t; | |
477 | 477 | |||
478 | if ((t = tp->t_tspec) == STRUCT || t == UNION) { | 478 | if ((t = tp->t_tspec) == STRUCT || t == UNION) { | |
479 | if (tp->t_str->stdef == NULL) | 479 | if (tp->t_str->stdef == NULL) | |
480 | tp->t_str->stdef = sym; | 480 | tp->t_str->stdef = sym; | |
481 | } else if (t == ENUM) { | 481 | } else if (t == ENUM) { | |
482 | if (tp->t_enum->etdef == NULL) | 482 | if (tp->t_enum->etdef == NULL) | |
483 | tp->t_enum->etdef = sym; | 483 | tp->t_enum->etdef = sym; | |
484 | } | 484 | } | |
485 | } | 485 | } | |
486 | 486 | |||
487 | void | |||
488 | addpacked(void) | |||
489 | { | |||
490 | str_t *sp; | |||
491 | sym_t *mem; | |||
492 | type_t *tp = dcs->d_type; | |||
493 | char buf[256]; | |||
494 | ||||
495 | if (tp == NULL) | |||
496 | LERROR("no type attr"); | |||
497 | ||||
498 | tp->t_ispacked = 1; | |||
499 | ||||
500 | switch (tp->t_tspec) { | |||
501 | case STRUCT: | |||
502 | sp = tp->t_str; | |||
503 | sp->size = 0; | |||
504 | for (mem = sp->memb; mem != NULL; mem = mem->s_nxt) | |||
505 | sp->size += size(mem->s_type->t_tspec); | |||
506 | break; | |||
507 | case UNION: | |||
508 | sp = tp->t_str; | |||
509 | sp->size = 0; | |||
510 | for (mem = sp->memb; mem != NULL; mem = mem->s_nxt) { | |||
511 | size_t x = size(mem->s_type->t_tspec); | |||
512 | if (x > sp->size) | |||
513 | sp->size = x; | |||
514 | } | |||
515 | break; | |||
516 | default: | |||
517 | warning(326, "packed", tyname(buf, sizeof(buf), tp)); | |||
518 | break; | |||
519 | } | |||
520 | } | |||
521 | ||||
487 | /* | 522 | /* | |
488 | * Remember a qualifier which is part of the declaration specifiers | 523 | * Remember a qualifier which is part of the declaration specifiers | |
489 | * (and not the declarator) in the top element of the declaration stack. | 524 | * (and not the declarator) in the top element of the declaration stack. | |
490 | * Also detect multiple qualifiers of the same kind. | 525 | * Also detect multiple qualifiers of the same kind. | |
491 | 526 | |||
492 | * The remembered qualifier is used by deftyp() to construct the type | 527 | * The remembered qualifier is used by deftyp() to construct the type | |
493 | * for all declarators. | 528 | * for all declarators. | |
494 | */ | 529 | */ | |
495 | void | 530 | void | |
496 | addqual(tqual_t q) | 531 | addqual(tqual_t q) | |
497 | { | 532 | { | |
498 | 533 | |||
499 | if (q == CONST) { | 534 | if (q == CONST) { | |
@@ -512,47 +547,47 @@ addqual(tqual_t q) | @@ -512,47 +547,47 @@ addqual(tqual_t q) | |||
512 | dcs->d_volatile = 1; | 547 | dcs->d_volatile = 1; | |
513 | } | 548 | } | |
514 | } | 549 | } | |
515 | 550 | |||
516 | /* | 551 | /* | |
517 | * Go to the next declaration level (structs, nested structs, blocks, | 552 | * Go to the next declaration level (structs, nested structs, blocks, | |
518 | * argument declaration lists ...) | 553 | * argument declaration lists ...) | |
519 | */ | 554 | */ | |
520 | void | 555 | void | |
521 | pushdecl(scl_t sc) | 556 | pushdecl(scl_t sc) | |
522 | { | 557 | { | |
523 | dinfo_t *di; | 558 | dinfo_t *di; | |
524 | 559 | |||
525 | if (dflag) | |||
526 | (void)printf("pushdecl(%d)\n", (int)sc); | |||
527 | ||||
528 | /* put a new element on the declaration stack */ | 560 | /* put a new element on the declaration stack */ | |
529 | di = xcalloc(1, sizeof (dinfo_t)); | 561 | di = xcalloc(1, sizeof (dinfo_t)); | |
530 | di->d_nxt = dcs; | 562 | di->d_nxt = dcs; | |
531 | dcs = di; | 563 | dcs = di; | |
532 | di->d_ctx = sc; | 564 | di->d_ctx = sc; | |
533 | di->d_ldlsym = &di->d_dlsyms; | 565 | di->d_ldlsym = &di->d_dlsyms; | |
566 | if (dflag) | |||
567 | (void)printf("pushdecl(%p %d)\n", dcs, (int)sc); | |||
568 | ||||
534 | } | 569 | } | |
535 | 570 | |||
536 | /* | 571 | /* | |
537 | * Go back to previous declaration level | 572 | * Go back to previous declaration level | |
538 | */ | 573 | */ | |
539 | void | 574 | void | |
540 | popdecl(void) | 575 | popdecl(void) | |
541 | { | 576 | { | |
542 | dinfo_t *di; | 577 | dinfo_t *di; | |
543 | 578 | |||
544 | if (dflag) | 579 | if (dflag) | |
545 | (void)printf("popdecl(%d)\n", (int)dcs->d_ctx); | 580 | (void)printf("popdecl(%p %d)\n", dcs, (int)dcs->d_ctx); | |
546 | 581 | |||
547 | if (dcs->d_nxt == NULL) | 582 | if (dcs->d_nxt == NULL) | |
548 | LERROR("popdecl()"); | 583 | LERROR("popdecl()"); | |
549 | di = dcs; | 584 | di = dcs; | |
550 | dcs = di->d_nxt; | 585 | dcs = di->d_nxt; | |
551 | switch (di->d_ctx) { | 586 | switch (di->d_ctx) { | |
552 | case EXTERN: | 587 | case EXTERN: | |
553 | /* there is nothing after external declarations */ | 588 | /* there is nothing after external declarations */ | |
554 | LERROR("popdecl()"); | 589 | LERROR("popdecl()"); | |
555 | /* NOTREACHED */ | 590 | /* NOTREACHED */ | |
556 | case MOS: | 591 | case MOS: | |
557 | case MOU: | 592 | case MOU: | |
558 | case ENUMCON: | 593 | case ENUMCON: | |
@@ -1607,27 +1642,26 @@ mktag(sym_t *tag, tspec_t kind, int decl | @@ -1607,27 +1642,26 @@ mktag(sym_t *tag, tspec_t kind, int decl | |||
1607 | tp->t_tspec = kind; | 1642 | tp->t_tspec = kind; | |
1608 | if (kind != ENUM) { | 1643 | if (kind != ENUM) { | |
1609 | tp->t_str = getblk(sizeof (str_t)); | 1644 | tp->t_str = getblk(sizeof (str_t)); | |
1610 | tp->t_str->align = CHAR_BIT; | 1645 | tp->t_str->align = CHAR_BIT; | |
1611 | tp->t_str->stag = tag; | 1646 | tp->t_str->stag = tag; | |
1612 | } else { | 1647 | } else { | |
1613 | tp->t_isenum = 1; | 1648 | tp->t_isenum = 1; | |
1614 | tp->t_enum = getblk(sizeof (enum_t)); | 1649 | tp->t_enum = getblk(sizeof (enum_t)); | |
1615 | tp->t_enum->etag = tag; | 1650 | tp->t_enum->etag = tag; | |
1616 | } | 1651 | } | |
1617 | /* ist unvollstaendiger Typ */ | 1652 | /* ist unvollstaendiger Typ */ | |
1618 | setcompl(tp, 1); | 1653 | setcompl(tp, 1); | |
1619 | } | 1654 | } | |
1620 | ||||
1621 | return (tp); | 1655 | return (tp); | |
1622 | } | 1656 | } | |
1623 | 1657 | |||
1624 | /* | 1658 | /* | |
1625 | * Checks all possible cases of tag redeclarations. | 1659 | * Checks all possible cases of tag redeclarations. | |
1626 | * decl is 1 if T_LBRACE follows | 1660 | * decl is 1 if T_LBRACE follows | |
1627 | * semi is 1 if T_SEMI follows | 1661 | * semi is 1 if T_SEMI follows | |
1628 | */ | 1662 | */ | |
1629 | static sym_t * | 1663 | static sym_t * | |
1630 | newtag(sym_t *tag, scl_t scl, int decl, int semi) | 1664 | newtag(sym_t *tag, scl_t scl, int decl, int semi) | |
1631 | { | 1665 | { | |
1632 | 1666 | |||
1633 | if (tag->s_blklev < blklev) { | 1667 | if (tag->s_blklev < blklev) { |
--- src/usr.bin/xlint/lint1/err.c 2009/05/02 16:10:49 1.42
+++ src/usr.bin/xlint/lint1/err.c 2009/10/02 15:03:45 1.43
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: err.c,v 1.42 2009/05/02 16:10:49 christos Exp $ */ | 1 | /* $NetBSD: err.c,v 1.43 2009/10/02 15:03:45 christos 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: err.c,v 1.42 2009/05/02 16:10:49 christos Exp $"); | 40 | __RCSID("$NetBSD: err.c,v 1.43 2009/10/02 15:03:45 christos Exp $"); | |
41 | #endif | 41 | #endif | |
42 | 42 | |||
43 | #include <sys/types.h> | 43 | #include <sys/types.h> | |
44 | #include <stdlib.h> | 44 | #include <stdlib.h> | |
45 | #include <stdarg.h> | 45 | #include <stdarg.h> | |
46 | 46 | |||
47 | #include "lint1.h" | 47 | #include "lint1.h" | |
48 | 48 | |||
49 | /* number of errors found */ | 49 | /* number of errors found */ | |
50 | int nerr; | 50 | int nerr; | |
51 | 51 | |||
52 | /* number of syntax errors */ | 52 | /* number of syntax errors */ | |
53 | int sytxerr; | 53 | int sytxerr; | |
@@ -375,26 +375,27 @@ const char *msgs[] = { | @@ -375,26 +375,27 @@ const char *msgs[] = { | |||
375 | "struct or union member name in initializer is a C9X feature",/* 313 */ | 375 | "struct or union member name in initializer is a C9X feature",/* 313 */ | |
376 | "%s is not a structure or a union", /* 314 */ | 376 | "%s is not a structure or a union", /* 314 */ | |
377 | "GCC style struct or union member name in initializer", /* 315 */ | 377 | "GCC style struct or union member name in initializer", /* 315 */ | |
378 | "__FUNCTION__ is a GCC extension", /* 316 */ | 378 | "__FUNCTION__ is a GCC extension", /* 316 */ | |
379 | "__func__ is a C9X feature", /* 317 */ | 379 | "__func__ is a C9X feature", /* 317 */ | |
380 | "variable array dimension is a C99/GCC extension", /* 318 */ | 380 | "variable array dimension is a C99/GCC extension", /* 318 */ | |
381 | "compound literals are a C9X/GCC extension", /* 319 */ | 381 | "compound literals are a C9X/GCC extension", /* 319 */ | |
382 | "({ }) is a GCC extension", /* 320 */ | 382 | "({ }) is a GCC extension", /* 320 */ | |
383 | "array initializer with designators is a C9X feature", /* 321 */ | 383 | "array initializer with designators is a C9X feature", /* 321 */ | |
384 | "zero sized array is a C99 extension", /* 322 */ | 384 | "zero sized array is a C99 extension", /* 322 */ | |
385 | "continue in 'do ... while (0)' loop", /* 323 */ | 385 | "continue in 'do ... while (0)' loop", /* 323 */ | |
386 | "suggest cast from '%s' to '%s' on op %s to avoid overflow", /* 324 */ | 386 | "suggest cast from '%s' to '%s' on op %s to avoid overflow", /* 324 */ | |
387 | "variable declaration in for loop", /* 325 */ | 387 | "variable declaration in for loop", /* 325 */ | |
388 | "%s attribute ignored for %s", /* 326 */ | |||
388 | }; | 389 | }; | |
389 | 390 | |||
390 | /* | 391 | /* | |
391 | * print a list of the messages with their ids | 392 | * print a list of the messages with their ids | |
392 | */ | 393 | */ | |
393 | void | 394 | void | |
394 | msglist(void) | 395 | msglist(void) | |
395 | { | 396 | { | |
396 | size_t i; | 397 | size_t i; | |
397 | 398 | |||
398 | for (i = 0; i < sizeof(msgs) / sizeof(msgs[0]); i++) | 399 | for (i = 0; i < sizeof(msgs) / sizeof(msgs[0]); i++) | |
399 | printf("%zu\t%s\n", i, msgs[i]); | 400 | printf("%zu\t%s\n", i, msgs[i]); | |
400 | } | 401 | } |
--- src/usr.bin/xlint/lint1/externs1.h 2009/05/02 16:10:49 1.27
+++ src/usr.bin/xlint/lint1/externs1.h 2009/10/02 15:03:45 1.28
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: externs1.h,v 1.27 2009/05/02 16:10:49 christos Exp $ */ | 1 | /* $NetBSD: externs1.h,v 1.28 2009/10/02 15:03:45 christos 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. | |
@@ -131,26 +131,27 @@ extern void lerror(const char *, int, co | @@ -131,26 +131,27 @@ extern void lerror(const char *, int, co | |||
131 | extern dinfo_t *dcs; | 131 | extern dinfo_t *dcs; | |
132 | extern const char *unnamed; | 132 | extern const char *unnamed; | |
133 | extern int enumval; | 133 | extern int enumval; | |
134 | 134 | |||
135 | extern void initdecl(void); | 135 | extern void initdecl(void); | |
136 | extern type_t *gettyp(tspec_t); | 136 | extern type_t *gettyp(tspec_t); | |
137 | extern type_t *duptyp(const type_t *); | 137 | extern type_t *duptyp(const type_t *); | |
138 | extern type_t *tduptyp(const type_t *); | 138 | extern type_t *tduptyp(const type_t *); | |
139 | extern int incompl(type_t *); | 139 | extern int incompl(type_t *); | |
140 | extern void setcompl(type_t *, int); | 140 | extern void setcompl(type_t *, int); | |
141 | extern void addscl(scl_t); | 141 | extern void addscl(scl_t); | |
142 | extern void addtype(type_t *); | 142 | extern void addtype(type_t *); | |
143 | extern void addqual(tqual_t); | 143 | extern void addqual(tqual_t); | |
144 | extern void addpacked(void); | |||
144 | extern void pushdecl(scl_t); | 145 | extern void pushdecl(scl_t); | |
145 | extern void popdecl(void); | 146 | extern void popdecl(void); | |
146 | extern void setasm(void); | 147 | extern void setasm(void); | |
147 | extern void clrtyp(void); | 148 | extern void clrtyp(void); | |
148 | extern void deftyp(void); | 149 | extern void deftyp(void); | |
149 | extern int length(type_t *, const char *); | 150 | extern int length(type_t *, const char *); | |
150 | extern int getbound(type_t *); | 151 | extern int getbound(type_t *); | |
151 | extern sym_t *lnklst(sym_t *, sym_t *); | 152 | extern sym_t *lnklst(sym_t *, sym_t *); | |
152 | extern void chktyp(sym_t *); | 153 | extern void chktyp(sym_t *); | |
153 | extern sym_t *decl1str(sym_t *); | 154 | extern sym_t *decl1str(sym_t *); | |
154 | extern sym_t *bitfield(sym_t *, int); | 155 | extern sym_t *bitfield(sym_t *, int); | |
155 | extern pqinf_t *mergepq(pqinf_t *, pqinf_t *); | 156 | extern pqinf_t *mergepq(pqinf_t *, pqinf_t *); | |
156 | extern sym_t *addptr(sym_t *, pqinf_t *); | 157 | extern sym_t *addptr(sym_t *, pqinf_t *); |
--- src/usr.bin/xlint/lint1/lint1.h 2008/12/10 16:12:39 1.22
+++ src/usr.bin/xlint/lint1/lint1.h 2009/10/02 15:03:45 1.23
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: lint1.h,v 1.22 2008/12/10 16:12:39 joerg Exp $ */ | 1 | /* $NetBSD: lint1.h,v 1.23 2009/10/02 15:03:45 christos 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 | |
@@ -133,26 +133,27 @@ typedef struct { | @@ -133,26 +133,27 @@ typedef struct { | |||
133 | * Types are represented by concatenation of structures of type type_t | 133 | * Types are represented by concatenation of structures of type type_t | |
134 | * via t_subt. | 134 | * via t_subt. | |
135 | */ | 135 | */ | |
136 | struct type { | 136 | struct type { | |
137 | tspec_t t_tspec; /* type specifier */ | 137 | tspec_t t_tspec; /* type specifier */ | |
138 | u_int t_aincompl : 1; /* incomplete array type */ | 138 | u_int t_aincompl : 1; /* incomplete array type */ | |
139 | u_int t_const : 1; /* const modifier */ | 139 | u_int t_const : 1; /* const modifier */ | |
140 | u_int t_volatile : 1; /* volatile modifier */ | 140 | u_int t_volatile : 1; /* volatile modifier */ | |
141 | u_int t_proto : 1; /* function prototype (t_args valid) */ | 141 | u_int t_proto : 1; /* function prototype (t_args valid) */ | |
142 | u_int t_vararg : 1; /* prototype with ... */ | 142 | u_int t_vararg : 1; /* prototype with ... */ | |
143 | u_int t_typedef : 1; /* type defined with typedef */ | 143 | u_int t_typedef : 1; /* type defined with typedef */ | |
144 | u_int t_isfield : 1; /* type is bitfield */ | 144 | u_int t_isfield : 1; /* type is bitfield */ | |
145 | u_int t_isenum : 1; /* type is (or was) enum (t_enum valid) */ | 145 | u_int t_isenum : 1; /* type is (or was) enum (t_enum valid) */ | |
146 | u_int t_ispacked : 1; /* type is packed */ | |||
146 | union { | 147 | union { | |
147 | int _t_dim; /* dimension */ | 148 | int _t_dim; /* dimension */ | |
148 | str_t *_t_str; /* struct/union tag */ | 149 | str_t *_t_str; /* struct/union tag */ | |
149 | enum_t *_t_enum; /* enum tag */ | 150 | enum_t *_t_enum; /* enum tag */ | |
150 | struct sym *_t_args; /* arguments (if t_proto) */ | 151 | struct sym *_t_args; /* arguments (if t_proto) */ | |
151 | } t_u; | 152 | } t_u; | |
152 | struct { | 153 | struct { | |
153 | u_int _t_flen : 8; /* length of bit-field */ | 154 | u_int _t_flen : 8; /* length of bit-field */ | |
154 | u_int _t_foffs : 24; /* offset of bit-field */ | 155 | u_int _t_foffs : 24; /* offset of bit-field */ | |
155 | } t_b; | 156 | } t_b; | |
156 | struct type *t_subt; /* element type (arrays), return value | 157 | struct type *t_subt; /* element type (arrays), return value | |
157 | (functions), or type pointer points to */ | 158 | (functions), or type pointer points to */ | |
158 | }; | 159 | }; |