Sun Feb 27 10:44:45 2022 UTC ()
lint: unabbreviate some fields in sym_t

No functional change.


(rillig)
diff -r1.247 -r1.248 src/usr.bin/xlint/lint1/decl.c
diff -r1.127 -r1.128 src/usr.bin/xlint/lint1/func.c
diff -r1.101 -r1.102 src/usr.bin/xlint/lint1/lex.c
diff -r1.138 -r1.139 src/usr.bin/xlint/lint1/lint1.h
diff -r1.406 -r1.407 src/usr.bin/xlint/lint1/tree.c

cvs diff -r1.247 -r1.248 src/usr.bin/xlint/lint1/decl.c (expand / switch to unified diff)

--- src/usr.bin/xlint/lint1/decl.c 2022/02/27 10:31:58 1.247
+++ src/usr.bin/xlint/lint1/decl.c 2022/02/27 10:44:45 1.248
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: decl.c,v 1.247 2022/02/27 10:31:58 rillig Exp $ */ 1/* $NetBSD: decl.c,v 1.248 2022/02/27 10:44:45 rillig Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. 4 * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
5 * Copyright (c) 1994, 1995 Jochen Pohl 5 * Copyright (c) 1994, 1995 Jochen Pohl
6 * All Rights Reserved. 6 * All Rights Reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -28,27 +28,27 @@ @@ -28,27 +28,27 @@
28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */ 33 */
34 34
35#if HAVE_NBTOOL_CONFIG_H 35#if HAVE_NBTOOL_CONFIG_H
36#include "nbtool_config.h" 36#include "nbtool_config.h"
37#endif 37#endif
38 38
39#include <sys/cdefs.h> 39#include <sys/cdefs.h>
40#if defined(__RCSID) && !defined(lint) 40#if defined(__RCSID) && !defined(lint)
41__RCSID("$NetBSD: decl.c,v 1.247 2022/02/27 10:31:58 rillig Exp $"); 41__RCSID("$NetBSD: decl.c,v 1.248 2022/02/27 10:44:45 rillig Exp $");
42#endif 42#endif
43 43
44#include <sys/param.h> 44#include <sys/param.h>
45#include <limits.h> 45#include <limits.h>
46#include <stdlib.h> 46#include <stdlib.h>
47#include <string.h> 47#include <string.h>
48 48
49#include "lint1.h" 49#include "lint1.h"
50 50
51const char *unnamed = "<unnamed>"; 51const char *unnamed = "<unnamed>";
52 52
53/* shared type structures for arithmetic types and void */ 53/* shared type structures for arithmetic types and void */
54static type_t *typetab; 54static type_t *typetab;
@@ -1430,27 +1430,27 @@ add_function(sym_t *decl, sym_t *args) @@ -1430,27 +1430,27 @@ add_function(sym_t *decl, sym_t *args)
1430 * Called for new style function declarations. 1430 * Called for new style function declarations.
1431 */ 1431 */
1432/* ARGSUSED */ 1432/* ARGSUSED */
1433static sym_t * 1433static sym_t *
1434new_style_function(sym_t *decl, sym_t *args) 1434new_style_function(sym_t *decl, sym_t *args)
1435{ 1435{
1436 sym_t *arg, *sym; 1436 sym_t *arg, *sym;
1437 scl_t sc; 1437 scl_t sc;
1438 1438
1439 /* 1439 /*
1440 * Declarations of structs/unions/enums in param lists are legal, 1440 * Declarations of structs/unions/enums in param lists are legal,
1441 * but senseless. 1441 * but senseless.
1442 */ 1442 */
1443 for (sym = dcs->d_dlsyms; sym != NULL; sym = sym->s_dlnxt) { 1443 for (sym = dcs->d_dlsyms; sym != NULL; sym = sym->s_level_next) {
1444 sc = sym->s_scl; 1444 sc = sym->s_scl;
1445 if (sc == STRUCT_TAG || sc == UNION_TAG || sc == ENUM_TAG) { 1445 if (sc == STRUCT_TAG || sc == UNION_TAG || sc == ENUM_TAG) {
1446 /* dubious tag declaration: %s %s */ 1446 /* dubious tag declaration: %s %s */
1447 warning(85, storage_class_name(sc), sym->s_name); 1447 warning(85, storage_class_name(sc), sym->s_name);
1448 } 1448 }
1449 } 1449 }
1450 1450
1451 for (arg = args; arg != NULL; arg = arg->s_next) { 1451 for (arg = args; arg != NULL; arg = arg->s_next) {
1452 if (arg->s_type->t_tspec == VOID && 1452 if (arg->s_type->t_tspec == VOID &&
1453 !(arg == args && arg->s_next == NULL)) { 1453 !(arg == args && arg->s_next == NULL)) {
1454 /* void must be sole parameter */ 1454 /* void must be sole parameter */
1455 error(60); 1455 error(60);
1456 arg->s_type = gettyp(INT); 1456 arg->s_type = gettyp(INT);
@@ -2766,27 +2766,27 @@ declare_local(sym_t *dsym, bool initflg) @@ -2766,27 +2766,27 @@ declare_local(sym_t *dsym, bool initflg)
2766 2766
2767/* 2767/*
2768 * Processes (re)declarations of external symbols inside blocks. 2768 * Processes (re)declarations of external symbols inside blocks.
2769 */ 2769 */
2770static void 2770static void
2771declare_external_in_block(sym_t *dsym) 2771declare_external_in_block(sym_t *dsym)
2772{ 2772{
2773 bool eqt, dowarn; 2773 bool eqt, dowarn;
2774 sym_t *esym; 2774 sym_t *esym;
2775 2775
2776 /* look for a symbol with the same name */ 2776 /* look for a symbol with the same name */
2777 esym = dcs->d_redeclared_symbol; 2777 esym = dcs->d_redeclared_symbol;
2778 while (esym != NULL && esym->s_block_level != 0) { 2778 while (esym != NULL && esym->s_block_level != 0) {
2779 while ((esym = esym->s_link) != NULL) { 2779 while ((esym = esym->s_symtab_next) != NULL) {
2780 if (esym->s_kind != FVFT) 2780 if (esym->s_kind != FVFT)
2781 continue; 2781 continue;
2782 if (strcmp(dsym->s_name, esym->s_name) == 0) 2782 if (strcmp(dsym->s_name, esym->s_name) == 0)
2783 break; 2783 break;
2784 } 2784 }
2785 } 2785 }
2786 if (esym == NULL) 2786 if (esym == NULL)
2787 return; 2787 return;
2788 if (esym->s_scl != EXTERN && esym->s_scl != STATIC) { 2788 if (esym->s_scl != EXTERN && esym->s_scl != STATIC) {
2789 /* gcc accepts this without a warning, pcc prints an error. */ 2789 /* gcc accepts this without a warning, pcc prints an error. */
2790 /* redeclaration of %s */ 2790 /* redeclaration of %s */
2791 warning(27, dsym->s_name); 2791 warning(27, dsym->s_name);
2792 print_previous_declaration(-1, esym); 2792 print_previous_declaration(-1, esym);
@@ -2974,40 +2974,40 @@ mark_as_used(sym_t *sym, bool fcall, boo @@ -2974,40 +2974,40 @@ mark_as_used(sym_t *sym, bool fcall, boo
2974 /* 2974 /*
2975 * for function calls another record is written 2975 * for function calls another record is written
2976 * 2976 *
2977 * XXX Should symbols used in sizeof() be treated as used or not? 2977 * XXX Should symbols used in sizeof() be treated as used or not?
2978 * Probably not, because there is no sense to declare an 2978 * Probably not, because there is no sense to declare an
2979 * external variable only to get their size. 2979 * external variable only to get their size.
2980 */ 2980 */
2981 if (!fcall && !szof && sym->s_kind == FVFT && sym->s_scl == EXTERN) 2981 if (!fcall && !szof && sym->s_kind == FVFT && sym->s_scl == EXTERN)
2982 outusg(sym); 2982 outusg(sym);
2983} 2983}
2984 2984
2985/* 2985/*
2986 * Prints warnings for a list of variables and labels (concatenated 2986 * Prints warnings for a list of variables and labels (concatenated
2987 * with s_dlnxt) if these are not used or only set. 2987 * with s_level_next) if these are not used or only set.
2988 */ 2988 */
2989void 2989void
2990check_usage(dinfo_t *di) 2990check_usage(dinfo_t *di)
2991{ 2991{
2992 sym_t *sym; 2992 sym_t *sym;
2993 int mklwarn; 2993 int mklwarn;
2994 2994
2995 /* for this warning LINTED has no effect */ 2995 /* for this warning LINTED has no effect */
2996 mklwarn = lwarn; 2996 mklwarn = lwarn;
2997 lwarn = LWARN_ALL; 2997 lwarn = LWARN_ALL;
2998 2998
2999 debug_step("begin lwarn %d", lwarn); 2999 debug_step("begin lwarn %d", lwarn);
3000 for (sym = di->d_dlsyms; sym != NULL; sym = sym->s_dlnxt) 3000 for (sym = di->d_dlsyms; sym != NULL; sym = sym->s_level_next)
3001 check_usage_sym(di->d_asm, sym); 3001 check_usage_sym(di->d_asm, sym);
3002 lwarn = mklwarn; 3002 lwarn = mklwarn;
3003 debug_step("end lwarn %d", lwarn); 3003 debug_step("end lwarn %d", lwarn);
3004} 3004}
3005 3005
3006/* 3006/*
3007 * Prints a warning for a single variable or label if it is not used or 3007 * Prints a warning for a single variable or label if it is not used or
3008 * only set. 3008 * only set.
3009 */ 3009 */
3010void 3010void
3011check_usage_sym(bool novar, sym_t *sym) 3011check_usage_sym(bool novar, sym_t *sym)
3012{ 3012{
3013 3013
@@ -3160,27 +3160,27 @@ check_tag_usage(sym_t *sym) @@ -3160,27 +3160,27 @@ check_tag_usage(sym_t *sym)
3160 * Performs some tests on global symbols. Detected problems are: 3160 * Performs some tests on global symbols. Detected problems are:
3161 * - defined variables of incomplete type 3161 * - defined variables of incomplete type
3162 * - constant variables which are not initialized 3162 * - constant variables which are not initialized
3163 * - static symbols which are never used 3163 * - static symbols which are never used
3164 */ 3164 */
3165void 3165void
3166check_global_symbols(void) 3166check_global_symbols(void)
3167{ 3167{
3168 sym_t *sym; 3168 sym_t *sym;
3169 3169
3170 if (block_level != 0 || dcs->d_next != NULL) 3170 if (block_level != 0 || dcs->d_next != NULL)
3171 norecover(); 3171 norecover();
3172 3172
3173 for (sym = dcs->d_dlsyms; sym != NULL; sym = sym->s_dlnxt) { 3173 for (sym = dcs->d_dlsyms; sym != NULL; sym = sym->s_level_next) {
3174 if (sym->s_block_level == -1) 3174 if (sym->s_block_level == -1)
3175 continue; 3175 continue;
3176 if (sym->s_kind == FVFT) { 3176 if (sym->s_kind == FVFT) {
3177 check_global_variable(sym); 3177 check_global_variable(sym);
3178 } else if (sym->s_kind == FTAG) { 3178 } else if (sym->s_kind == FTAG) {
3179 check_tag_usage(sym); 3179 check_tag_usage(sym);
3180 } else { 3180 } else {
3181 lint_assert(sym->s_kind == FMEMBER); 3181 lint_assert(sym->s_kind == FMEMBER);
3182 } 3182 }
3183 } 3183 }
3184} 3184}
3185 3185
3186static void 3186static void

cvs diff -r1.127 -r1.128 src/usr.bin/xlint/lint1/func.c (expand / switch to unified diff)

--- src/usr.bin/xlint/lint1/func.c 2022/02/27 08:31:26 1.127
+++ src/usr.bin/xlint/lint1/func.c 2022/02/27 10:44:45 1.128
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: func.c,v 1.127 2022/02/27 08:31:26 rillig Exp $ */ 1/* $NetBSD: func.c,v 1.128 2022/02/27 10:44:45 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: func.c,v 1.127 2022/02/27 08:31:26 rillig Exp $"); 40__RCSID("$NetBSD: func.c,v 1.128 2022/02/27 10:44:45 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#include "cgram.h" 47#include "cgram.h"
48 48
49/* 49/*
50 * Contains a pointer to the symbol table entry of the current function 50 * Contains a pointer to the symbol table entry of the current function
51 * definition. 51 * definition.
52 */ 52 */
53sym_t *funcsym; 53sym_t *funcsym;
@@ -225,27 +225,28 @@ check_statement_reachable(void) @@ -225,27 +225,28 @@ check_statement_reachable(void)
225void 225void
226funcdef(sym_t *fsym) 226funcdef(sym_t *fsym)
227{ 227{
228 int n; 228 int n;
229 bool dowarn; 229 bool dowarn;
230 sym_t *arg, *sym, *rdsym; 230 sym_t *arg, *sym, *rdsym;
231 231
232 funcsym = fsym; 232 funcsym = fsym;
233 233
234 /* 234 /*
235 * Put all symbols declared in the argument list back to the 235 * Put all symbols declared in the argument list back to the
236 * symbol table. 236 * symbol table.
237 */ 237 */
238 for (sym = dcs->d_func_proto_syms; sym != NULL; sym = sym->s_dlnxt) { 238 for (sym = dcs->d_func_proto_syms; sym != NULL;
 239 sym = sym->s_level_next) {
239 if (sym->s_block_level != -1) { 240 if (sym->s_block_level != -1) {
240 lint_assert(sym->s_block_level == 1); 241 lint_assert(sym->s_block_level == 1);
241 inssym(1, sym); 242 inssym(1, sym);
242 } 243 }
243 } 244 }
244 245
245 /* 246 /*
246 * In old_style_function() we did not know whether it is an old 247 * In old_style_function() we did not know whether it is an old
247 * style function definition or only an old style declaration, 248 * style function definition or only an old style declaration,
248 * if there are no arguments inside the argument list ("f()"). 249 * if there are no arguments inside the argument list ("f()").
249 */ 250 */
250 if (!fsym->s_type->t_proto && fsym->s_args == NULL) 251 if (!fsym->s_type->t_proto && fsym->s_args == NULL)
251 fsym->s_osdef = true; 252 fsym->s_osdef = true;

cvs diff -r1.101 -r1.102 src/usr.bin/xlint/lint1/lex.c (expand / switch to unified diff)

--- src/usr.bin/xlint/lint1/lex.c 2022/02/27 08:31:26 1.101
+++ src/usr.bin/xlint/lint1/lex.c 2022/02/27 10:44:45 1.102
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: lex.c,v 1.101 2022/02/27 08:31:26 rillig Exp $ */ 1/* $NetBSD: lex.c,v 1.102 2022/02/27 10:44:45 rillig Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. 4 * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
5 * Copyright (c) 1994, 1995 Jochen Pohl 5 * Copyright (c) 1994, 1995 Jochen Pohl
6 * All Rights Reserved. 6 * All Rights Reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -28,27 +28,27 @@ @@ -28,27 +28,27 @@
28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */ 33 */
34 34
35#if HAVE_NBTOOL_CONFIG_H 35#if HAVE_NBTOOL_CONFIG_H
36#include "nbtool_config.h" 36#include "nbtool_config.h"
37#endif 37#endif
38 38
39#include <sys/cdefs.h> 39#include <sys/cdefs.h>
40#if defined(__RCSID) && !defined(lint) 40#if defined(__RCSID) && !defined(lint)
41__RCSID("$NetBSD: lex.c,v 1.101 2022/02/27 08:31:26 rillig Exp $"); 41__RCSID("$NetBSD: lex.c,v 1.102 2022/02/27 10:44:45 rillig Exp $");
42#endif 42#endif
43 43
44#include <ctype.h> 44#include <ctype.h>
45#include <errno.h> 45#include <errno.h>
46#include <float.h> 46#include <float.h>
47#include <limits.h> 47#include <limits.h>
48#include <math.h> 48#include <math.h>
49#include <stdlib.h> 49#include <stdlib.h>
50#include <string.h> 50#include <string.h>
51 51
52#include "lint1.h" 52#include "lint1.h"
53#include "cgram.h" 53#include "cgram.h"
54 54
@@ -256,39 +256,39 @@ static struct keyword { @@ -256,39 +256,39 @@ static struct keyword {
256/* Symbol table */ 256/* Symbol table */
257static sym_t *symtab[HSHSIZ1]; 257static sym_t *symtab[HSHSIZ1];
258 258
259/* type of next expected symbol */ 259/* type of next expected symbol */
260symt_t symtyp; 260symt_t symtyp;
261 261
262 262
263static void 263static void
264symtab_add(sym_t *sym) 264symtab_add(sym_t *sym)
265{ 265{
266 size_t h; 266 size_t h;
267 267
268 h = hash(sym->s_name); 268 h = hash(sym->s_name);
269 if ((sym->s_link = symtab[h]) != NULL) 269 if ((sym->s_symtab_next = symtab[h]) != NULL)
270 symtab[h]->s_rlink = &sym->s_link; 270 symtab[h]->s_symtab_ref = &sym->s_symtab_next;
271 sym->s_rlink = &symtab[h]; 271 sym->s_symtab_ref = &symtab[h];
272 symtab[h] = sym; 272 symtab[h] = sym;
273} 273}
274 274
275static void 275static void
276symtab_remove(sym_t *sym) 276symtab_remove(sym_t *sym)
277{ 277{
278 278
279 if ((*sym->s_rlink = sym->s_link) != NULL) 279 if ((*sym->s_symtab_ref = sym->s_symtab_next) != NULL)
280 sym->s_link->s_rlink = sym->s_rlink; 280 sym->s_symtab_next->s_symtab_ref = sym->s_symtab_ref;
281 sym->s_link = NULL; 281 sym->s_symtab_next = NULL;
282} 282}
283 283
284 284
285static void 285static void
286add_keyword(const struct keyword *kw, bool leading, bool trailing) 286add_keyword(const struct keyword *kw, bool leading, bool trailing)
287{ 287{
288 sym_t *sym; 288 sym_t *sym;
289 char buf[256]; 289 char buf[256];
290 const char *name; 290 const char *name;
291 291
292 if (!leading && !trailing) { 292 if (!leading && !trailing) {
293 name = kw->kw_name; 293 name = kw->kw_name;
294 } else { 294 } else {
@@ -416,27 +416,27 @@ lex_name(const char *yytext, size_t yyle @@ -416,27 +416,27 @@ lex_name(const char *yytext, size_t yyle
416 416
417 yylval.y_name = sb; 417 yylval.y_name = sb;
418 return tok; 418 return tok;
419} 419}
420 420
421static sym_t * 421static sym_t *
422search(sbuf_t *sb) 422search(sbuf_t *sb)
423{ 423{
424 unsigned int h; 424 unsigned int h;
425 sym_t *sym; 425 sym_t *sym;
426 const struct keyword *kw; 426 const struct keyword *kw;
427 427
428 h = hash(sb->sb_name); 428 h = hash(sb->sb_name);
429 for (sym = symtab[h]; sym != NULL; sym = sym->s_link) { 429 for (sym = symtab[h]; sym != NULL; sym = sym->s_symtab_next) {
430 if (strcmp(sym->s_name, sb->sb_name) != 0) 430 if (strcmp(sym->s_name, sb->sb_name) != 0)
431 continue; 431 continue;
432 kw = sym->s_keyword; 432 kw = sym->s_keyword;
433 433
434 if (kw != NULL && !kw->kw_attr) 434 if (kw != NULL && !kw->kw_attr)
435 return sym; 435 return sym;
436 if (kw != NULL && in_gcc_attribute) 436 if (kw != NULL && in_gcc_attribute)
437 return sym; 437 return sym;
438 if (kw == NULL && !in_gcc_attribute && sym->s_kind == symtyp) 438 if (kw == NULL && !in_gcc_attribute && sym->s_kind == symtyp)
439 return sym; 439 return sym;
440 } 440 }
441 441
442 return NULL; 442 return NULL;
@@ -1367,27 +1367,27 @@ getsym(sbuf_t *sb) @@ -1367,27 +1367,27 @@ getsym(sbuf_t *sb)
1367 sym->s_block_level = block_level; 1367 sym->s_block_level = block_level;
1368 di = dcs; 1368 di = dcs;
1369 } 1369 }
1370 1370
1371 UNIQUE_CURR_POS(sym->s_def_pos); 1371 UNIQUE_CURR_POS(sym->s_def_pos);
1372 if ((sym->s_kind = symtyp) != FLABEL) 1372 if ((sym->s_kind = symtyp) != FLABEL)
1373 sym->s_type = gettyp(INT); 1373 sym->s_type = gettyp(INT);
1374 1374
1375 symtyp = FVFT; 1375 symtyp = FVFT;
1376 1376
1377 symtab_add(sym); 1377 symtab_add(sym);
1378 1378
1379 *di->d_ldlsym = sym; 1379 *di->d_ldlsym = sym;
1380 di->d_ldlsym = &sym->s_dlnxt; 1380 di->d_ldlsym = &sym->s_level_next;
1381 1381
1382 free(sb); 1382 free(sb);
1383 return sym; 1383 return sym;
1384} 1384}
1385 1385
1386/* 1386/*
1387 * Construct a temporary symbol. The symbol name starts with a digit, making 1387 * Construct a temporary symbol. The symbol name starts with a digit, making
1388 * the name illegal. 1388 * the name illegal.
1389 */ 1389 */
1390sym_t * 1390sym_t *
1391mktempsym(type_t *t) 1391mktempsym(type_t *t)
1392{ 1392{
1393 static int n = 0; 1393 static int n = 0;
@@ -1402,95 +1402,95 @@ mktempsym(type_t *t) @@ -1402,95 +1402,95 @@ mktempsym(type_t *t)
1402 scl = block_level > 0 ? AUTO : EXTERN; 1402 scl = block_level > 0 ? AUTO : EXTERN;
1403 1403
1404 sym->s_name = s; 1404 sym->s_name = s;
1405 sym->s_type = t; 1405 sym->s_type = t;
1406 sym->s_block_level = block_level; 1406 sym->s_block_level = block_level;
1407 sym->s_scl = scl; 1407 sym->s_scl = scl;
1408 sym->s_kind = FVFT; 1408 sym->s_kind = FVFT;
1409 sym->s_used = true; 1409 sym->s_used = true;
1410 sym->s_set = true; 1410 sym->s_set = true;
1411 1411
1412 symtab_add(sym); 1412 symtab_add(sym);
1413 1413
1414 *dcs->d_ldlsym = sym; 1414 *dcs->d_ldlsym = sym;
1415 dcs->d_ldlsym = &sym->s_dlnxt; 1415 dcs->d_ldlsym = &sym->s_level_next;
1416 1416
1417 return sym; 1417 return sym;
1418} 1418}
1419 1419
1420/* Remove a symbol forever from the symbol table. */ 1420/* Remove a symbol forever from the symbol table. */
1421void 1421void
1422rmsym(sym_t *sym) 1422rmsym(sym_t *sym)
1423{ 1423{
1424 1424
1425 debug_step("rmsym '%s' %s '%s'", 1425 debug_step("rmsym '%s' %s '%s'",
1426 sym->s_name, symt_name(sym->s_kind), type_name(sym->s_type)); 1426 sym->s_name, symt_name(sym->s_kind), type_name(sym->s_type));
1427 symtab_remove(sym); 1427 symtab_remove(sym);
1428 1428
1429 /* avoid that the symbol will later be put back to the symbol table */ 1429 /* avoid that the symbol will later be put back to the symbol table */
1430 sym->s_block_level = -1; 1430 sym->s_block_level = -1;
1431} 1431}
1432 1432
1433/* 1433/*
1434 * Remove a list of symbols declared at one level from the symbol 1434 * Remove a list of symbols declared at one level from the symbol
1435 * table. 1435 * table.
1436 */ 1436 */
1437void 1437void
1438rmsyms(sym_t *syms) 1438rmsyms(sym_t *syms)
1439{ 1439{
1440 sym_t *sym; 1440 sym_t *sym;
1441 1441
1442 for (sym = syms; sym != NULL; sym = sym->s_dlnxt) { 1442 for (sym = syms; sym != NULL; sym = sym->s_level_next) {
1443 if (sym->s_block_level != -1) { 1443 if (sym->s_block_level != -1) {
1444 debug_step("rmsyms '%s' %s '%s'", 1444 debug_step("rmsyms '%s' %s '%s'",
1445 sym->s_name, symt_name(sym->s_kind), 1445 sym->s_name, symt_name(sym->s_kind),
1446 type_name(sym->s_type)); 1446 type_name(sym->s_type));
1447 symtab_remove(sym); 1447 symtab_remove(sym);
1448 sym->s_rlink = NULL; 1448 sym->s_symtab_ref = NULL;
1449 } 1449 }
1450 } 1450 }
1451} 1451}
1452 1452
1453/* 1453/*
1454 * Put a symbol into the symbol table. 1454 * Put a symbol into the symbol table.
1455 */ 1455 */
1456void 1456void
1457inssym(int bl, sym_t *sym) 1457inssym(int bl, sym_t *sym)
1458{ 1458{
1459 1459
1460 debug_step("inssym '%s' %s '%s'", 1460 debug_step("inssym '%s' %s '%s'",
1461 sym->s_name, symt_name(sym->s_kind), type_name(sym->s_type)); 1461 sym->s_name, symt_name(sym->s_kind), type_name(sym->s_type));
1462 symtab_add(sym); 1462 symtab_add(sym);
1463 sym->s_block_level = bl; 1463 sym->s_block_level = bl;
1464 lint_assert(sym->s_link == NULL || 1464 lint_assert(sym->s_symtab_next == NULL ||
1465 sym->s_block_level >= sym->s_link->s_block_level); 1465 sym->s_block_level >= sym->s_symtab_next->s_block_level);
1466} 1466}
1467 1467
1468/* 1468/*
1469 * Called at level 0 after syntax errors. 1469 * Called at level 0 after syntax errors.
1470 * 1470 *
1471 * Removes all symbols which are not declared at level 0 from the 1471 * Removes all symbols which are not declared at level 0 from the
1472 * symbol table. Also frees all memory which is not associated with 1472 * symbol table. Also frees all memory which is not associated with
1473 * level 0. 1473 * level 0.
1474 */ 1474 */
1475void 1475void
1476cleanup(void) 1476cleanup(void)
1477{ 1477{
1478 sym_t *sym, *nsym; 1478 sym_t *sym, *nsym;
1479 size_t i; 1479 size_t i;
1480 1480
1481 for (i = 0; i < HSHSIZ1; i++) { 1481 for (i = 0; i < HSHSIZ1; i++) {
1482 for (sym = symtab[i]; sym != NULL; sym = nsym) { 1482 for (sym = symtab[i]; sym != NULL; sym = nsym) {
1483 nsym = sym->s_link; 1483 nsym = sym->s_symtab_next;
1484 if (sym->s_block_level >= 1) 1484 if (sym->s_block_level >= 1)
1485 symtab_remove(sym); 1485 symtab_remove(sym);
1486 } 1486 }
1487 } 1487 }
1488 1488
1489 for (i = mem_block_level; i > 0; i--) 1489 for (i = mem_block_level; i > 0; i--)
1490 level_free_all(i); 1490 level_free_all(i);
1491} 1491}
1492 1492
1493/* 1493/*
1494 * Create a new symbol with the name of an existing symbol. 1494 * Create a new symbol with the name of an existing symbol.
1495 */ 1495 */
1496sym_t * 1496sym_t *
@@ -1500,27 +1500,27 @@ pushdown(const sym_t *sym) @@ -1500,27 +1500,27 @@ pushdown(const sym_t *sym)
1500 1500
1501 debug_step("pushdown '%s' %s '%s'", 1501 debug_step("pushdown '%s' %s '%s'",
1502 sym->s_name, symt_name(sym->s_kind), type_name(sym->s_type)); 1502 sym->s_name, symt_name(sym->s_kind), type_name(sym->s_type));
1503 nsym = block_zero_alloc(sizeof(*nsym)); 1503 nsym = block_zero_alloc(sizeof(*nsym));
1504 lint_assert(sym->s_block_level <= block_level); 1504 lint_assert(sym->s_block_level <= block_level);
1505 nsym->s_name = sym->s_name; 1505 nsym->s_name = sym->s_name;
1506 UNIQUE_CURR_POS(nsym->s_def_pos); 1506 UNIQUE_CURR_POS(nsym->s_def_pos);
1507 nsym->s_kind = sym->s_kind; 1507 nsym->s_kind = sym->s_kind;
1508 nsym->s_block_level = block_level; 1508 nsym->s_block_level = block_level;
1509 1509
1510 symtab_add(nsym); 1510 symtab_add(nsym);
1511 1511
1512 *dcs->d_ldlsym = nsym; 1512 *dcs->d_ldlsym = nsym;
1513 dcs->d_ldlsym = &nsym->s_dlnxt; 1513 dcs->d_ldlsym = &nsym->s_level_next;
1514 1514
1515 return nsym; 1515 return nsym;
1516} 1516}
1517 1517
1518/* 1518/*
1519 * Free any dynamically allocated memory referenced by 1519 * Free any dynamically allocated memory referenced by
1520 * the value stack or yylval. 1520 * the value stack or yylval.
1521 * The type of information in yylval is described by tok. 1521 * The type of information in yylval is described by tok.
1522 */ 1522 */
1523void 1523void
1524freeyyv(void *sp, int tok) 1524freeyyv(void *sp, int tok)
1525{ 1525{
1526 if (tok == T_NAME || tok == T_TYPENAME) { 1526 if (tok == T_NAME || tok == T_TYPENAME) {

cvs diff -r1.138 -r1.139 src/usr.bin/xlint/lint1/lint1.h (expand / switch to unified diff)

--- src/usr.bin/xlint/lint1/lint1.h 2022/02/27 07:50:09 1.138
+++ src/usr.bin/xlint/lint1/lint1.h 2022/02/27 10:44:45 1.139
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: lint1.h,v 1.138 2022/02/27 07:50:09 rillig Exp $ */ 1/* $NetBSD: lint1.h,v 1.139 2022/02/27 10:44:45 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
@@ -263,31 +263,33 @@ typedef struct sym { @@ -263,31 +263,33 @@ typedef struct sym {
263 int s_block_level; /* level of declaration, -1 if not in symbol 263 int s_block_level; /* level of declaration, -1 if not in symbol
264 table */ 264 table */
265 type_t *s_type; 265 type_t *s_type;
266 val_t s_value; /* value (if enum or bool constant) */ 266 val_t s_value; /* value (if enum or bool constant) */
267 union { 267 union {
268 /* XXX: what is the difference to s_type->t_str? */ 268 /* XXX: what is the difference to s_type->t_str? */
269 struct_or_union *_s_st; 269 struct_or_union *_s_st;
270 enumeration *_s_et; 270 enumeration *_s_et;
271 tspec_t _s_tsp; /* type (only for keywords) */ 271 tspec_t _s_tsp; /* type (only for keywords) */
272 tqual_t _s_tqu; /* qualifier (only for keywords) */ 272 tqual_t _s_tqu; /* qualifier (only for keywords) */
273 struct sym *_s_args; /* arguments in old style function 273 struct sym *_s_args; /* arguments in old style function
274 definitions */ 274 definitions */
275 } u; 275 } u;
276 struct sym *s_link; /* next symbol with same hash value */ 276 struct sym *s_symtab_next; /* next symbol with same hash value */
277 struct sym **s_rlink; /* pointer to s_link of prev. symbol */ 277 struct sym **s_symtab_ref; /* pointer to s_symtab_next of the
 278 * previous symbol */
278 struct sym *s_next; /* next struct/union member, enumerator, 279 struct sym *s_next; /* next struct/union member, enumerator,
279 argument */ 280 argument */
280 struct sym *s_dlnxt; /* next symbol declared on same level */ 281 struct sym *s_level_next; /* next symbol declared on the same
 282 * level */
281} sym_t; 283} sym_t;
282 284
283#define s_styp u._s_st 285#define s_styp u._s_st
284#define s_etyp u._s_et 286#define s_etyp u._s_et
285#define s_tspec u._s_tsp 287#define s_tspec u._s_tsp
286#define s_tqual u._s_tqu 288#define s_tqual u._s_tqu
287#define s_args u._s_args 289#define s_args u._s_args
288 290
289/* 291/*
290 * Used to keep some information about symbols before they are entered 292 * Used to keep some information about symbols before they are entered
291 * into the symbol table. 293 * into the symbol table.
292 */ 294 */
293typedef struct sbuf { 295typedef struct sbuf {
@@ -377,28 +379,28 @@ typedef struct dinfo { @@ -377,28 +379,28 @@ typedef struct dinfo {
377 bool d_invalid_type_combination:1; 379 bool d_invalid_type_combination:1;
378 bool d_nonempty_decl:1; /* if at least one tag is declared 380 bool d_nonempty_decl:1; /* if at least one tag is declared
379 * ... in the current function decl. */ 381 * ... in the current function decl. */
380 bool d_vararg:1; 382 bool d_vararg:1;
381 bool d_proto:1; /* current function decl. is prototype */ 383 bool d_proto:1; /* current function decl. is prototype */
382 bool d_notyp:1; /* set if no type specifier was present */ 384 bool d_notyp:1; /* set if no type specifier was present */
383 bool d_asm:1; /* set if d_ctx == AUTO and asm() present */ 385 bool d_asm:1; /* set if d_ctx == AUTO and asm() present */
384 bool d_packed:1; 386 bool d_packed:1;
385 bool d_used:1; 387 bool d_used:1;
386 type_t *d_tagtyp; /* tag during member declaration */ 388 type_t *d_tagtyp; /* tag during member declaration */
387 sym_t *d_func_args; /* list of arguments during function def. */ 389 sym_t *d_func_args; /* list of arguments during function def. */
388 pos_t d_func_def_pos; /* position of function definition */ 390 pos_t d_func_def_pos; /* position of function definition */
389 sym_t *d_dlsyms; /* first symbol declared at this level */ 391 sym_t *d_dlsyms; /* first symbol declared at this level */
390 sym_t **d_ldlsym; /* points to s_dlnxt in last symbol decl. 392 sym_t **d_ldlsym; /* points to s_level_next in the last symbol
391 at this level */ 393 declaration at this level */
392 sym_t *d_func_proto_syms; /* symbols defined in prototype */ 394 sym_t *d_func_proto_syms; /* symbols defined in prototype */
393 struct dinfo *d_next; /* next level */ 395 struct dinfo *d_next; /* next level */
394} dinfo_t; 396} dinfo_t;
395 397
396/* One level of pointer indirection in declarators, including qualifiers. */ 398/* One level of pointer indirection in declarators, including qualifiers. */
397typedef struct qual_ptr { 399typedef struct qual_ptr {
398 bool p_const: 1; 400 bool p_const: 1;
399 bool p_volatile: 1; 401 bool p_volatile: 1;
400 bool p_pointer: 1; 402 bool p_pointer: 1;
401 struct qual_ptr *p_next; 403 struct qual_ptr *p_next;
402} qual_ptr; 404} qual_ptr;
403 405
404/* 406/*

cvs diff -r1.406 -r1.407 src/usr.bin/xlint/lint1/tree.c (expand / switch to unified diff)

--- src/usr.bin/xlint/lint1/tree.c 2022/02/27 10:31:58 1.406
+++ src/usr.bin/xlint/lint1/tree.c 2022/02/27 10:44:45 1.407
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: tree.c,v 1.406 2022/02/27 10:31:58 rillig Exp $ */ 1/* $NetBSD: tree.c,v 1.407 2022/02/27 10:44:45 rillig Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1994, 1995 Jochen Pohl 4 * Copyright (c) 1994, 1995 Jochen Pohl
5 * All Rights Reserved. 5 * All Rights Reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -27,27 +27,27 @@ @@ -27,27 +27,27 @@
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */ 32 */
33 33
34#if HAVE_NBTOOL_CONFIG_H 34#if HAVE_NBTOOL_CONFIG_H
35#include "nbtool_config.h" 35#include "nbtool_config.h"
36#endif 36#endif
37 37
38#include <sys/cdefs.h> 38#include <sys/cdefs.h>
39#if defined(__RCSID) && !defined(lint) 39#if defined(__RCSID) && !defined(lint)
40__RCSID("$NetBSD: tree.c,v 1.406 2022/02/27 10:31:58 rillig Exp $"); 40__RCSID("$NetBSD: tree.c,v 1.407 2022/02/27 10:44:45 rillig Exp $");
41#endif 41#endif
42 42
43#include <float.h> 43#include <float.h>
44#include <limits.h> 44#include <limits.h>
45#include <math.h> 45#include <math.h>
46#include <signal.h> 46#include <signal.h>
47#include <stdlib.h> 47#include <stdlib.h>
48#include <string.h> 48#include <string.h>
49 49
50#include "lint1.h" 50#include "lint1.h"
51#include "cgram.h" 51#include "cgram.h"
52 52
53static tnode_t *build_integer_constant(tspec_t, int64_t); 53static tnode_t *build_integer_constant(tspec_t, int64_t);
@@ -369,48 +369,49 @@ struct_or_union_member(tnode_t *tn, op_t @@ -369,48 +369,49 @@ struct_or_union_member(tnode_t *tn, op_t
369 if (op == POINT) { 369 if (op == POINT) {
370 if (t == STRUCT || t == UNION) 370 if (t == STRUCT || t == UNION)
371 str = tp->t_str; 371 str = tp->t_str;
372 } else if (op == ARROW && t == PTR) { 372 } else if (op == ARROW && t == PTR) {
373 t = (tp = tp->t_subt)->t_tspec; 373 t = (tp = tp->t_subt)->t_tspec;
374 if (t == STRUCT || t == UNION) 374 if (t == STRUCT || t == UNION)
375 str = tp->t_str; 375 str = tp->t_str;
376 } 376 }
377 377
378 /* 378 /*
379 * If this struct/union has a member with the name of msym, return it. 379 * If this struct/union has a member with the name of msym, return it.
380 */ 380 */
381 if (str != NULL) { 381 if (str != NULL) {
382 for (sym = msym; sym != NULL; sym = sym->s_link) { 382 for (sym = msym; sym != NULL; sym = sym->s_symtab_next) {
383 if (sym->s_scl != MOS && sym->s_scl != MOU) 383 if (sym->s_scl != MOS && sym->s_scl != MOU)
384 continue; 384 continue;
385 if (sym->s_styp != str) 385 if (sym->s_styp != str)
386 continue; 386 continue;
387 if (strcmp(sym->s_name, msym->s_name) != 0) 387 if (strcmp(sym->s_name, msym->s_name) != 0)
388 continue; 388 continue;
389 return sym; 389 return sym;
390 } 390 }
391 } 391 }
392 392
393 /* 393 /*
394 * Set eq to false if there are struct/union members with the same 394 * Set eq to false if there are struct/union members with the same
395 * name and different types and/or offsets. 395 * name and different types and/or offsets.
396 */ 396 */
397 eq = true; 397 eq = true;
398 for (csym = msym; csym != NULL; csym = csym->s_link) { 398 for (csym = msym; csym != NULL; csym = csym->s_symtab_next) {
399 if (csym->s_scl != MOS && csym->s_scl != MOU) 399 if (csym->s_scl != MOS && csym->s_scl != MOU)
400 continue; 400 continue;
401 if (strcmp(msym->s_name, csym->s_name) != 0) 401 if (strcmp(msym->s_name, csym->s_name) != 0)
402 continue; 402 continue;
403 for (sym = csym->s_link; sym != NULL; sym = sym->s_link) { 403 for (sym = csym->s_symtab_next; sym != NULL;
 404 sym = sym->s_symtab_next) {
404 bool w; 405 bool w;
405 406
406 if (sym->s_scl != MOS && sym->s_scl != MOU) 407 if (sym->s_scl != MOS && sym->s_scl != MOU)
407 continue; 408 continue;
408 if (strcmp(csym->s_name, sym->s_name) != 0) 409 if (strcmp(csym->s_name, sym->s_name) != 0)
409 continue; 410 continue;
410 if (csym->s_value.v_quad != sym->s_value.v_quad) { 411 if (csym->s_value.v_quad != sym->s_value.v_quad) {
411 eq = false; 412 eq = false;
412 break; 413 break;
413 } 414 }
414 w = false; 415 w = false;
415 eq = eqtype(csym->s_type, sym->s_type, 416 eq = eqtype(csym->s_type, sym->s_type,
416 false, false, &w) && !w; 417 false, false, &w) && !w;