Sun Feb 27 11:14:42 2022 UTC ()
lint: unabbreviate two more members of sym_t

No functional change.


(rillig)
diff -r1.383 -r1.384 src/usr.bin/xlint/lint1/cgram.y
diff -r1.248 -r1.249 src/usr.bin/xlint/lint1/decl.c
diff -r1.140 -r1.141 src/usr.bin/xlint/lint1/lint1.h
diff -r1.407 -r1.408 src/usr.bin/xlint/lint1/tree.c

cvs diff -r1.383 -r1.384 src/usr.bin/xlint/lint1/cgram.y (expand / switch to unified diff)

--- src/usr.bin/xlint/lint1/cgram.y 2022/02/27 08:31:26 1.383
+++ src/usr.bin/xlint/lint1/cgram.y 2022/02/27 11:14:42 1.384
@@ -1,15 +1,15 @@ @@ -1,15 +1,15 @@
1%{ 1%{
2/* $NetBSD: cgram.y,v 1.383 2022/02/27 08:31:26 rillig Exp $ */ 2/* $NetBSD: cgram.y,v 1.384 2022/02/27 11:14:42 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: cgram.y,v 1.383 2022/02/27 08:31:26 rillig Exp $"); 38__RCSID("$NetBSD: cgram.y,v 1.384 2022/02/27 11:14:42 rillig Exp $");
39#endif 39#endif
40 40
41#include <limits.h> 41#include <limits.h>
42#include <stdlib.h> 42#include <stdlib.h>
43#include <string.h> 43#include <string.h>
44 44
45#include "lint1.h" 45#include "lint1.h"
46 46
47extern char *yytext; 47extern char *yytext;
48 48
49/* 49/*
50 * Contains the level of current declaration, used for symbol table entries. 50 * Contains the level of current declaration, used for symbol table entries.
51 * 0 is the top-level, > 0 is inside a function body. 51 * 0 is the top-level, > 0 is inside a function body.
@@ -104,27 +104,27 @@ RESTORE_WARN_FLAGS(const char *file, siz @@ -104,27 +104,27 @@ RESTORE_WARN_FLAGS(const char *file, siz
104#define RESTORE_WARN_FLAGS(f, l) \ 104#define RESTORE_WARN_FLAGS(f, l) \
105 (void)(olwarn == LWARN_BAD ? (clear_warn_flags(), 0) : (lwarn = olwarn)) 105 (void)(olwarn == LWARN_BAD ? (clear_warn_flags(), 0) : (lwarn = olwarn))
106#endif 106#endif
107 107
108#define clear_warning_flags() CLEAR_WARN_FLAGS(__FILE__, __LINE__) 108#define clear_warning_flags() CLEAR_WARN_FLAGS(__FILE__, __LINE__)
109#define save_warning_flags() SAVE_WARN_FLAGS(__FILE__, __LINE__) 109#define save_warning_flags() SAVE_WARN_FLAGS(__FILE__, __LINE__)
110#define restore_warning_flags() RESTORE_WARN_FLAGS(__FILE__, __LINE__) 110#define restore_warning_flags() RESTORE_WARN_FLAGS(__FILE__, __LINE__)
111 111
112/* unbind the anonymous struct members from the struct */ 112/* unbind the anonymous struct members from the struct */
113static void 113static void
114anonymize(sym_t *s) 114anonymize(sym_t *s)
115{ 115{
116 for ( ; s != NULL; s = s->s_next) 116 for ( ; s != NULL; s = s->s_next)
117 s->s_styp = NULL; 117 s->s_sou_type = NULL;
118} 118}
119 119
120#if defined(YYDEBUG) && (defined(YYBYACC) || defined(YYBISON)) 120#if defined(YYDEBUG) && (defined(YYBYACC) || defined(YYBISON))
121#define YYSTYPE_TOSTRING cgram_to_string 121#define YYSTYPE_TOSTRING cgram_to_string
122#endif 122#endif
123#if defined(YYDEBUG) && defined(YYBISON) 123#if defined(YYDEBUG) && defined(YYBISON)
124#define YYPRINT cgram_print 124#define YYPRINT cgram_print
125#endif 125#endif
126 126
127%} 127%}
128 128
129%expect 150 129%expect 150
130 130

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

--- src/usr.bin/xlint/lint1/decl.c 2022/02/27 10:44:45 1.248
+++ src/usr.bin/xlint/lint1/decl.c 2022/02/27 11:14:42 1.249
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: decl.c,v 1.248 2022/02/27 10:44:45 rillig Exp $ */ 1/* $NetBSD: decl.c,v 1.249 2022/02/27 11:14:42 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.248 2022/02/27 10:44:45 rillig Exp $"); 41__RCSID("$NetBSD: decl.c,v 1.249 2022/02/27 11:14:42 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;
@@ -1147,27 +1147,27 @@ declarator_1_struct_union(sym_t *dsym) @@ -1147,27 +1147,27 @@ declarator_1_struct_union(sym_t *dsym)
1147{ 1147{
1148 type_t *tp; 1148 type_t *tp;
1149 tspec_t t; 1149 tspec_t t;
1150 int sz; 1150 int sz;
1151 unsigned int o = 0; /* Appease GCC */ 1151 unsigned int o = 0; /* Appease GCC */
1152 1152
1153 lint_assert(dsym->s_scl == MOS || dsym->s_scl == MOU); 1153 lint_assert(dsym->s_scl == MOS || dsym->s_scl == MOU);
1154 1154
1155 if (dcs->d_redeclared_symbol != NULL) { 1155 if (dcs->d_redeclared_symbol != NULL) {
1156 /* should be ensured by storesym() */ 1156 /* should be ensured by storesym() */
1157 lint_assert(dcs->d_redeclared_symbol->s_scl == MOS || 1157 lint_assert(dcs->d_redeclared_symbol->s_scl == MOS ||
1158 dcs->d_redeclared_symbol->s_scl == MOU); 1158 dcs->d_redeclared_symbol->s_scl == MOU);
1159 1159
1160 if (dsym->s_styp == dcs->d_redeclared_symbol->s_styp) { 1160 if (dsym->s_sou_type == dcs->d_redeclared_symbol->s_sou_type) {
1161 /* duplicate member name: %s */ 1161 /* duplicate member name: %s */
1162 error(33, dsym->s_name); 1162 error(33, dsym->s_name);
1163 rmsym(dcs->d_redeclared_symbol); 1163 rmsym(dcs->d_redeclared_symbol);
1164 } 1164 }
1165 } 1165 }
1166 1166
1167 check_type(dsym); 1167 check_type(dsym);
1168 1168
1169 t = (tp = dsym->s_type)->t_tspec; 1169 t = (tp = dsym->s_type)->t_tspec;
1170 1170
1171 if (dsym->s_bitfield) { 1171 if (dsym->s_bitfield) {
1172 declare_bit_field(dsym, &t, &tp); 1172 declare_bit_field(dsym, &t, &tp);
1173 } else if (t == FUNC) { 1173 } else if (t == FUNC) {
@@ -1503,48 +1503,48 @@ check_function_definition(sym_t *sym, bo @@ -1503,48 +1503,48 @@ check_function_definition(sym_t *sym, bo
1503 if (msg) { 1503 if (msg) {
1504 /* incomplete or misplaced function definition */ 1504 /* incomplete or misplaced function definition */
1505 error(22); 1505 error(22);
1506 } 1506 }
1507 sym->s_osdef = false; 1507 sym->s_osdef = false;
1508 sym->s_args = NULL; 1508 sym->s_args = NULL;
1509 } 1509 }
1510} 1510}
1511 1511
1512/* 1512/*
1513 * Process the name in a declarator. 1513 * Process the name in a declarator.
1514 * The symbol gets one of the storage classes EXTERN, STATIC, AUTO or 1514 * The symbol gets one of the storage classes EXTERN, STATIC, AUTO or
1515 * TYPEDEF. 1515 * TYPEDEF.
1516 * s_def and s_reg are valid after declarator_name(). 1516 * s_def and s_register are valid after declarator_name().
1517 */ 1517 */
1518sym_t * 1518sym_t *
1519declarator_name(sym_t *sym) 1519declarator_name(sym_t *sym)
1520{ 1520{
1521 scl_t sc = NOSCL; 1521 scl_t sc = NOSCL;
1522 1522
1523 if (sym->s_scl == NOSCL) { 1523 if (sym->s_scl == NOSCL) {
1524 dcs->d_redeclared_symbol = NULL; 1524 dcs->d_redeclared_symbol = NULL;
1525 } else if (sym->s_defarg) { 1525 } else if (sym->s_defarg) {
1526 sym->s_defarg = false; 1526 sym->s_defarg = false;
1527 dcs->d_redeclared_symbol = NULL; 1527 dcs->d_redeclared_symbol = NULL;
1528 } else { 1528 } else {
1529 dcs->d_redeclared_symbol = sym; 1529 dcs->d_redeclared_symbol = sym;
1530 sym = pushdown(sym); 1530 sym = pushdown(sym);
1531 } 1531 }
1532 1532
1533 switch (dcs->d_ctx) { 1533 switch (dcs->d_ctx) {
1534 case MOS: 1534 case MOS:
1535 case MOU: 1535 case MOU:
1536 /* Set parent */ 1536 /* Set parent */
1537 sym->s_styp = dcs->d_tagtyp->t_str; 1537 sym->s_sou_type = dcs->d_tagtyp->t_str;
1538 sym->s_def = DEF; 1538 sym->s_def = DEF;
1539 sym->s_value.v_tspec = INT; 1539 sym->s_value.v_tspec = INT;
1540 sc = dcs->d_ctx; 1540 sc = dcs->d_ctx;
1541 break; 1541 break;
1542 case EXTERN: 1542 case EXTERN:
1543 /* 1543 /*
1544 * static and external symbols without "extern" are 1544 * static and external symbols without "extern" are
1545 * considered to be tentative defined, external 1545 * considered to be tentative defined, external
1546 * symbols with "extern" are declared, and typedef names 1546 * symbols with "extern" are declared, and typedef names
1547 * are defined. Tentative defined and declared symbols 1547 * are defined. Tentative defined and declared symbols
1548 * may become defined if an initializer is present or 1548 * may become defined if an initializer is present or
1549 * this is a function definition. 1549 * this is a function definition.
1550 */ 1550 */
@@ -1558,45 +1558,45 @@ declarator_name(sym_t *sym) @@ -1558,45 +1558,45 @@ declarator_name(sym_t *sym)
1558 } else { 1558 } else {
1559 lint_assert(sc == EXTERN); 1559 lint_assert(sc == EXTERN);
1560 sym->s_def = DECL; 1560 sym->s_def = DECL;
1561 } 1561 }
1562 break; 1562 break;
1563 case PROTO_ARG: 1563 case PROTO_ARG:
1564 sym->s_arg = true; 1564 sym->s_arg = true;
1565 /* FALLTHROUGH */ 1565 /* FALLTHROUGH */
1566 case OLD_STYLE_ARG: 1566 case OLD_STYLE_ARG:
1567 if ((sc = dcs->d_scl) == NOSCL) { 1567 if ((sc = dcs->d_scl) == NOSCL) {
1568 sc = AUTO; 1568 sc = AUTO;
1569 } else { 1569 } else {
1570 lint_assert(sc == REG); 1570 lint_assert(sc == REG);
1571 sym->s_reg = true; 1571 sym->s_register = true;
1572 sc = AUTO; 1572 sc = AUTO;
1573 } 1573 }
1574 sym->s_def = DEF; 1574 sym->s_def = DEF;
1575 break; 1575 break;
1576 case AUTO: 1576 case AUTO:
1577 if ((sc = dcs->d_scl) == NOSCL) { 1577 if ((sc = dcs->d_scl) == NOSCL) {
1578 /* 1578 /*
1579 * XXX somewhat ugly because we dont know whether 1579 * XXX somewhat ugly because we dont know whether
1580 * this is AUTO or EXTERN (functions). If we are 1580 * this is AUTO or EXTERN (functions). If we are
1581 * wrong it must be corrected in declare_local(), 1581 * wrong it must be corrected in declare_local(),
1582 * where we have the necessary type information. 1582 * where we have the necessary type information.
1583 */ 1583 */
1584 sc = AUTO; 1584 sc = AUTO;
1585 sym->s_def = DEF; 1585 sym->s_def = DEF;
1586 } else if (sc == AUTO || sc == STATIC || sc == TYPEDEF) { 1586 } else if (sc == AUTO || sc == STATIC || sc == TYPEDEF) {
1587 sym->s_def = DEF; 1587 sym->s_def = DEF;
1588 } else if (sc == REG) { 1588 } else if (sc == REG) {
1589 sym->s_reg = true; 1589 sym->s_register = true;
1590 sc = AUTO; 1590 sc = AUTO;
1591 sym->s_def = DEF; 1591 sym->s_def = DEF;
1592 } else { 1592 } else {
1593 lint_assert(sc == EXTERN); 1593 lint_assert(sc == EXTERN);
1594 sym->s_def = DECL; 1594 sym->s_def = DECL;
1595 } 1595 }
1596 break; 1596 break;
1597 default: 1597 default:
1598 lint_assert(/*CONSTCOND*/false); 1598 lint_assert(/*CONSTCOND*/false);
1599 } 1599 }
1600 sym->s_scl = sc; 1600 sym->s_scl = sc;
1601 1601
1602 sym->s_type = dcs->d_type; 1602 sym->s_type = dcs->d_type;
@@ -1800,28 +1800,28 @@ complete_tag_struct_or_union(type_t *tp, @@ -1800,28 +1800,28 @@ complete_tag_struct_or_union(type_t *tp,
1800 if (tp->t_packed) 1800 if (tp->t_packed)
1801 setpackedsize(tp); 1801 setpackedsize(tp);
1802 else 1802 else
1803 sp->sou_size_in_bits = dcs->d_offset; 1803 sp->sou_size_in_bits = dcs->d_offset;
1804 1804
1805 if (sp->sou_size_in_bits == 0) { 1805 if (sp->sou_size_in_bits == 0) {
1806 /* zero sized %s is a C9X feature */ 1806 /* zero sized %s is a C9X feature */
1807 c99ism(47, ttab[t].tt_name); 1807 c99ism(47, ttab[t].tt_name);
1808 } 1808 }
1809 1809
1810 n = 0; 1810 n = 0;
1811 for (mem = fmem; mem != NULL; mem = mem->s_next) { 1811 for (mem = fmem; mem != NULL; mem = mem->s_next) {
1812 /* bind anonymous members to the structure */ 1812 /* bind anonymous members to the structure */
1813 if (mem->s_styp == NULL) { 1813 if (mem->s_sou_type == NULL) {
1814 mem->s_styp = sp; 1814 mem->s_sou_type = sp;
1815 if (mem->s_type->t_bitfield) { 1815 if (mem->s_type->t_bitfield) {
1816 sp->sou_size_in_bits += bitfieldsize(&mem); 1816 sp->sou_size_in_bits += bitfieldsize(&mem);
1817 if (mem == NULL) 1817 if (mem == NULL)
1818 break; 1818 break;
1819 } 1819 }
1820 sp->sou_size_in_bits += 1820 sp->sou_size_in_bits +=
1821 type_size_in_bits(mem->s_type); 1821 type_size_in_bits(mem->s_type);
1822 } 1822 }
1823 if (mem->s_name != unnamed) 1823 if (mem->s_name != unnamed)
1824 n++; 1824 n++;
1825 } 1825 }
1826 1826
1827 if (n == 0 && sp->sou_size_in_bits != 0) { 1827 if (n == 0 && sp->sou_size_in_bits != 0) {

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

--- src/usr.bin/xlint/lint1/lint1.h 2022/02/27 10:49:15 1.140
+++ src/usr.bin/xlint/lint1/lint1.h 2022/02/27 11:14:42 1.141
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: lint1.h,v 1.140 2022/02/27 10:49:15 rillig Exp $ */ 1/* $NetBSD: lint1.h,v 1.141 2022/02/27 11:14:42 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
@@ -240,58 +240,59 @@ typedef struct sym { @@ -240,58 +240,59 @@ typedef struct sym {
240 const char *s_rename; /* renamed symbol's given name */ 240 const char *s_rename; /* renamed symbol's given name */
241 pos_t s_def_pos; /* position of last (prototype) definition, 241 pos_t s_def_pos; /* position of last (prototype) definition,
242 prototype declaration, no-prototype-def., 242 prototype declaration, no-prototype-def.,
243 tentative definition or declaration, 243 tentative definition or declaration,
244 in this order */ 244 in this order */
245 pos_t s_set_pos; /* position of first initialization */ 245 pos_t s_set_pos; /* position of first initialization */
246 pos_t s_use_pos; /* position of first use */ 246 pos_t s_use_pos; /* position of first use */
247 symt_t s_kind; /* type of symbol */ 247 symt_t s_kind; /* type of symbol */
248 const struct keyword *s_keyword; 248 const struct keyword *s_keyword;
249 bool s_bitfield:1; 249 bool s_bitfield:1;
250 bool s_set:1; /* variable set, label defined */ 250 bool s_set:1; /* variable set, label defined */
251 bool s_used:1; /* variable/label used */ 251 bool s_used:1; /* variable/label used */
252 bool s_arg:1; /* symbol is function argument */ 252 bool s_arg:1; /* symbol is function argument */
253 bool s_reg:1; /* symbol is register variable */ 253 bool s_register:1; /* symbol is register variable */
254 bool s_defarg:1; /* undefined symbol in old style function 254 bool s_defarg:1; /* undefined symbol in old style function
255 definition */ 255 definition */
256 bool s_return_type_implicit_int:1; 256 bool s_return_type_implicit_int:1;
257 bool s_osdef:1; /* symbol stems from old style function def. */ 257 bool s_osdef:1; /* symbol stems from old style function def. */
258 bool s_inline:1; /* true if this is an inline function */ 258 bool s_inline:1; /* true if this is an inline function */
259 struct sym *s_ext_sym; /* for local declared external symbols pointer 259 struct sym *s_ext_sym; /* for locally declared external symbols, the
260 to external symbol with same name */ 260 * pointer to the external symbol with the
 261 * same name */
261 def_t s_def; /* declared, tentative defined, defined */ 262 def_t s_def; /* declared, tentative defined, defined */
262 scl_t s_scl; /* storage class */ 263 scl_t s_scl; /* storage class */
263 int s_block_level; /* level of declaration, -1 if not in symbol 264 int s_block_level; /* level of declaration, -1 if not in symbol
264 table */ 265 table */
265 type_t *s_type; 266 type_t *s_type;
266 val_t s_value; /* value (if enum or bool constant) */ 267 val_t s_value; /* value (if enum or bool constant) */
267 union { 268 union {
268 /* XXX: what is the difference to s_type->t_str? */ 269 /* XXX: what is the difference to s_type->t_str? */
269 struct_or_union *_s_st; 270 struct_or_union *_s_st;
270 tspec_t _s_tsp; /* type (only for keywords) */ 271 tspec_t _s_tsp; /* type (only for keywords) */
271 tqual_t _s_tqu; /* qualifier (only for keywords) */ 272 tqual_t _s_tqu; /* qualifier (only for keywords) */
272 struct sym *_s_args; /* arguments in old style function 273 struct sym *_s_args; /* arguments in old style function
273 definitions */ 274 definitions */
274 } u; 275 } u;
275 struct sym *s_symtab_next; /* next symbol with same hash value */ 276 struct sym *s_symtab_next; /* next symbol with same hash value */
276 struct sym **s_symtab_ref; /* pointer to s_symtab_next of the 277 struct sym **s_symtab_ref; /* pointer to s_symtab_next of the
277 * previous symbol */ 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_level_next; /* next symbol declared on the same 281 struct sym *s_level_next; /* next symbol declared on the same
281 * level */ 282 * level */
282} sym_t; 283} sym_t;
283 284
284#define s_styp u._s_st 285#define s_sou_type u._s_st
285#define s_tspec u._s_tsp 286#define s_tspec u._s_tsp
286#define s_tqual u._s_tqu 287#define s_tqual u._s_tqu
287#define s_args u._s_args 288#define s_args u._s_args
288 289
289/* 290/*
290 * Used to keep some information about symbols before they are entered 291 * Used to keep some information about symbols before they are entered
291 * into the symbol table. 292 * into the symbol table.
292 */ 293 */
293typedef struct sbuf { 294typedef struct sbuf {
294 const char *sb_name; /* name of symbol */ 295 const char *sb_name; /* name of symbol */
295 size_t sb_len; /* length (without '\0') */ 296 size_t sb_len; /* length (without '\0') */
296 sym_t *sb_sym; /* symbol table entry */ 297 sym_t *sb_sym; /* symbol table entry */
297} sbuf_t; 298} sbuf_t;

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

--- src/usr.bin/xlint/lint1/tree.c 2022/02/27 10:44:45 1.407
+++ src/usr.bin/xlint/lint1/tree.c 2022/02/27 11:14:42 1.408
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: tree.c,v 1.407 2022/02/27 10:44:45 rillig Exp $ */ 1/* $NetBSD: tree.c,v 1.408 2022/02/27 11:14:42 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.407 2022/02/27 10:44:45 rillig Exp $"); 40__RCSID("$NetBSD: tree.c,v 1.408 2022/02/27 11:14:42 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);
@@ -345,54 +345,54 @@ struct_or_union_member(tnode_t *tn, op_t @@ -345,54 +345,54 @@ struct_or_union_member(tnode_t *tn, op_t
345 bool eq; 345 bool eq;
346 tspec_t t; 346 tspec_t t;
347 347
348 /* 348 /*
349 * Remove the member if it was unknown until now, which means 349 * Remove the member if it was unknown until now, which means
350 * that no defined struct or union has a member with the same name. 350 * that no defined struct or union has a member with the same name.
351 */ 351 */
352 if (msym->s_scl == NOSCL) { 352 if (msym->s_scl == NOSCL) {
353 /* type '%s' does not have member '%s' */ 353 /* type '%s' does not have member '%s' */
354 error(101, type_name(tn->tn_type), msym->s_name); 354 error(101, type_name(tn->tn_type), msym->s_name);
355 rmsym(msym); 355 rmsym(msym);
356 msym->s_kind = FMEMBER; 356 msym->s_kind = FMEMBER;
357 msym->s_scl = MOS; 357 msym->s_scl = MOS;
358 msym->s_styp = expr_zero_alloc(sizeof(*msym->s_styp)); 358 msym->s_sou_type = expr_zero_alloc(sizeof(*msym->s_sou_type));
359 msym->s_styp->sou_tag = expr_zero_alloc( 359 msym->s_sou_type->sou_tag = expr_zero_alloc(
360 sizeof(*msym->s_styp->sou_tag)); 360 sizeof(*msym->s_sou_type->sou_tag));
361 msym->s_styp->sou_tag->s_name = unnamed; 361 msym->s_sou_type->sou_tag->s_name = unnamed;
362 msym->s_value.v_tspec = INT; 362 msym->s_value.v_tspec = INT;
363 return msym; 363 return msym;
364 } 364 }
365 365
366 /* Set str to the tag of which msym is expected to be a member. */ 366 /* Set str to the tag of which msym is expected to be a member. */
367 str = NULL; 367 str = NULL;
368 t = (tp = tn->tn_type)->t_tspec; 368 t = (tp = tn->tn_type)->t_tspec;
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_symtab_next) { 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_sou_type != 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_symtab_next) { 398 for (csym = msym; csym != NULL; csym = csym->s_symtab_next) {
@@ -848,27 +848,27 @@ typeok_address(const mod_t *mp, @@ -848,27 +848,27 @@ typeok_address(const mod_t *mp,
848 error(114, "", mp->m_name); 848 error(114, "", mp->m_name);
849 return false; 849 return false;
850 } else if (is_scalar(t)) { 850 } else if (is_scalar(t)) {
851 if (tp->t_bitfield) { 851 if (tp->t_bitfield) {
852 /* cannot take address of bit-field */ 852 /* cannot take address of bit-field */
853 error(112); 853 error(112);
854 return false; 854 return false;
855 } 855 }
856 } else if (t != STRUCT && t != UNION) { 856 } else if (t != STRUCT && t != UNION) {
857 /* unacceptable operand of '%s' */ 857 /* unacceptable operand of '%s' */
858 error(111, mp->m_name); 858 error(111, mp->m_name);
859 return false; 859 return false;
860 } 860 }
861 if (tn->tn_op == NAME && tn->tn_sym->s_reg) { 861 if (tn->tn_op == NAME && tn->tn_sym->s_register) {
862 /* cannot take address of register %s */ 862 /* cannot take address of register %s */
863 error(113, tn->tn_sym->s_name); 863 error(113, tn->tn_sym->s_name);
864 return false; 864 return false;
865 } 865 }
866 return true; 866 return true;
867} 867}
868 868
869static bool 869static bool
870typeok_indir(tspec_t t) 870typeok_indir(tspec_t t)
871{ 871{
872 /* until now there were no type checks for this operator */ 872 /* until now there were no type checks for this operator */
873 if (t != PTR) { 873 if (t != PTR) {
874 /* cannot dereference non-pointer type */ 874 /* cannot dereference non-pointer type */