Module Name: src Committed By: rillig Date: Sat Mar 9 10:41:11 UTC 2024
Modified Files: src/usr.bin/xlint/lint1: cgram.y decl.c externs1.h lint1.h Log Message: lint: use fewer struct keywords To generate a diff of this commit: cvs rdiff -u -r1.489 -r1.490 src/usr.bin/xlint/lint1/cgram.y cvs rdiff -u -r1.394 -r1.395 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.218 -r1.219 src/usr.bin/xlint/lint1/externs1.h cvs rdiff -u -r1.215 -r1.216 src/usr.bin/xlint/lint1/lint1.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/xlint/lint1/cgram.y diff -u src/usr.bin/xlint/lint1/cgram.y:1.489 src/usr.bin/xlint/lint1/cgram.y:1.490 --- src/usr.bin/xlint/lint1/cgram.y:1.489 Thu Feb 8 20:45:20 2024 +++ src/usr.bin/xlint/lint1/cgram.y Sat Mar 9 10:41:11 2024 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.489 2024/02/08 20:45:20 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.490 2024/03/09 10:41:11 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -35,7 +35,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) -__RCSID("$NetBSD: cgram.y,v 1.489 2024/02/08 20:45:20 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.490 2024/03/09 10:41:11 rillig Exp $"); #endif #include <limits.h> @@ -128,7 +128,7 @@ is_either(const char *s, const char *a, tspec_t y_tspec; type_qualifiers y_type_qualifiers; function_specifier y_function_specifier; - struct parameter_list y_parameter_list; + parameter_list y_parameter_list; function_call *y_arguments; type_t *y_type; tnode_t *y_tnode; @@ -137,7 +137,7 @@ is_either(const char *s, const char *a, qual_ptr *y_qual_ptr; bool y_seen_statement; struct generic_association *y_generic; - struct array_size y_array_size; + array_size y_array_size; bool y_in_system_header; designation y_designation; }; @@ -1421,7 +1421,7 @@ param_list: block_level++; begin_declaration_level(DLK_PROTO_PARAMS); } identifier_list T_RPAREN { - $$ = (struct parameter_list){ .first = $3 }; + $$ = (parameter_list){ .first = $3 }; } | abstract_decl_param_list ; @@ -1541,7 +1541,7 @@ direct_abstract_declarator: abstract_decl_param_list: /* specific to lint */ abstract_decl_lparen T_RPAREN type_attribute_opt { - $$ = (struct parameter_list){ .first = NULL }; + $$ = (parameter_list){ .first = NULL }; } | abstract_decl_lparen vararg_parameter_type_list T_RPAREN type_attribute_opt { @@ -1549,7 +1549,7 @@ abstract_decl_param_list: /* specific to $$.prototype = true; } | abstract_decl_lparen error T_RPAREN type_attribute_opt { - $$ = (struct parameter_list){ .first = NULL }; + $$ = (parameter_list){ .first = NULL }; } ; @@ -1574,14 +1574,14 @@ vararg_parameter_type_list: /* specific else if (allow_c90) /* C90 to C17 require formal parameter before '...' */ warning(84); - $$ = (struct parameter_list){ .vararg = true }; + $$ = (parameter_list){ .vararg = true }; } ; /* XXX: C99 6.7.5 defines the same name, but it looks different. */ parameter_type_list: parameter_declaration { - $$ = (struct parameter_list){ .first = $1 }; + $$ = (parameter_list){ .first = $1 }; } | parameter_type_list T_COMMA parameter_declaration { $$ = $1; Index: src/usr.bin/xlint/lint1/decl.c diff -u src/usr.bin/xlint/lint1/decl.c:1.394 src/usr.bin/xlint/lint1/decl.c:1.395 --- src/usr.bin/xlint/lint1/decl.c:1.394 Sat Mar 2 09:32:18 2024 +++ src/usr.bin/xlint/lint1/decl.c Sat Mar 9 10:41:11 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.394 2024/03/02 09:32:18 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.395 2024/03/09 10:41:11 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) -__RCSID("$NetBSD: decl.c,v 1.394 2024/03/02 09:32:18 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.395 2024/03/09 10:41:11 rillig Exp $"); #endif #include <sys/param.h> @@ -1334,7 +1334,7 @@ old_style_function(sym_t *decl, sym_t *p } sym_t * -add_function(sym_t *decl, struct parameter_list params) +add_function(sym_t *decl, parameter_list params) { debug_enter(); Index: src/usr.bin/xlint/lint1/externs1.h diff -u src/usr.bin/xlint/lint1/externs1.h:1.218 src/usr.bin/xlint/lint1/externs1.h:1.219 --- src/usr.bin/xlint/lint1/externs1.h:1.218 Sun Mar 3 00:50:41 2024 +++ src/usr.bin/xlint/lint1/externs1.h Sat Mar 9 10:41:11 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: externs1.h,v 1.218 2024/03/03 00:50:41 rillig Exp $ */ +/* $NetBSD: externs1.h,v 1.219 2024/03/09 10:41:11 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -233,7 +233,7 @@ void add_type_qualifiers(type_qualifiers qual_ptr *append_qualified_pointer(qual_ptr *, qual_ptr *); sym_t *add_pointer(sym_t *, qual_ptr *); sym_t *add_array(sym_t *, bool, int); -sym_t *add_function(sym_t *, struct parameter_list); +sym_t *add_function(sym_t *, parameter_list); void check_extern_declaration(const sym_t *); void check_function_definition(sym_t *, bool); sym_t *declarator_name(sym_t *); Index: src/usr.bin/xlint/lint1/lint1.h diff -u src/usr.bin/xlint/lint1/lint1.h:1.215 src/usr.bin/xlint/lint1/lint1.h:1.216 --- src/usr.bin/xlint/lint1/lint1.h:1.215 Sun Mar 3 16:09:01 2024 +++ src/usr.bin/xlint/lint1/lint1.h Sat Mar 9 10:41:11 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: lint1.h,v 1.215 2024/03/03 16:09:01 rillig Exp $ */ +/* $NetBSD: lint1.h,v 1.216 2024/03/09 10:41:11 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -108,6 +108,8 @@ typedef struct { } u; } val_t; +typedef struct sym sym_t; + /* * Structures of type struct_or_union uniquely identify structures. This can't * be done in structures of type type_t, because these are copied if they must @@ -121,9 +123,9 @@ typedef struct { unsigned int sou_size_in_bits; unsigned int sou_align_in_bits; bool sou_incomplete:1; - struct sym *sou_first_member; - struct sym *sou_tag; - struct sym *sou_first_typedef; + sym_t *sou_first_member; + sym_t *sou_tag; + sym_t *sou_first_typedef; } struct_or_union; /* @@ -131,9 +133,9 @@ typedef struct { */ typedef struct { bool en_incomplete:1; - struct sym *en_first_enumerator; - struct sym *en_tag; - struct sym *en_first_typedef; + sym_t *en_first_enumerator; + sym_t *en_tag; + sym_t *en_first_typedef; } enumeration; /* @@ -165,7 +167,7 @@ struct lint1_type { int _t_dim; /* dimension (if ARRAY) */ struct_or_union *_t_sou; enumeration *_t_enum; - struct sym *_t_params; /* parameters (if t_proto) */ + sym_t *_t_params; /* parameters (if t_proto) */ } t_u; unsigned int t_bit_field_width:8; unsigned int t_bit_field_offset:24; @@ -218,7 +220,7 @@ typedef enum { /* * symbol table entry */ -typedef struct sym { +struct sym { const char *s_name; const char *s_rename; /* renamed symbol's given name */ pos_t s_def_pos; /* position of last (prototype) definition, @@ -268,20 +270,19 @@ typedef struct sym { struct sym *s_old_style_params; /* parameters in an old-style * function definition */ } u; - struct sym *s_symtab_next; /* next symbol with same hash value */ - struct sym **s_symtab_ref; /* pointer to s_symtab_next of the - * previous symbol */ - struct sym *s_next; /* next struct/union member, enumerator, + sym_t *s_symtab_next; /* next symbol in the same symtab bucket */ + sym_t **s_symtab_ref; /* pointer to s_symtab_next of the previous + * symbol */ + sym_t *s_next; /* next struct/union member, enumerator, * parameter */ - struct sym *s_level_next; /* next symbol declared on the same - * level */ -} sym_t; + sym_t *s_level_next; /* next symbol declared on the same level */ +}; /* * Used to keep some information about symbols before they are entered * into the symbol table. */ -typedef struct sbuf { +typedef struct { const char *sb_name; /* name of symbol */ size_t sb_len; /* length (without '\0') */ sym_t *sb_sym; /* symbol table entry */ @@ -295,10 +296,10 @@ typedef struct { size_t args_cap; } function_call; -/* - * tree node - */ -typedef struct tnode { +typedef struct tnode tnode_t; + +/* An expression, forming an abstract syntax tree. */ +struct tnode { op_t tn_op; /* operator */ type_t *tn_type; /* type */ bool tn_lvalue:1; /* node is lvalue */ @@ -311,8 +312,8 @@ typedef struct tnode { bool tn_system_dependent:1; /* depends on sizeof or offsetof */ union { struct { - struct tnode *_tn_left; /* (left) operand */ - struct tnode *_tn_right; /* right operand */ + tnode_t *_tn_left; /* (left) operand */ + tnode_t *_tn_right; /* right operand */ } tn_s; sym_t *_tn_sym; /* symbol if op == NAME */ val_t _tn_val; /* value if op == CON */ @@ -326,7 +327,7 @@ typedef struct tnode { * characters */ function_call *_tn_call; } tn_u; -} tnode_t; +}; #define tn_left tn_u.tn_s._tn_left #define tn_right tn_u.tn_s._tn_right @@ -341,10 +342,10 @@ struct generic_association { struct generic_association *ga_prev; }; -struct array_size { +typedef struct { bool has_dim; int dim; -}; +} array_size; typedef enum decl_level_kind { DLK_EXTERN, /* global types, variables or functions */ @@ -407,11 +408,11 @@ typedef struct decl_level { struct decl_level *d_enclosing; /* the enclosing declaration level */ } decl_level; -struct parameter_list { +typedef struct { sym_t *first; bool vararg:1; bool prototype:1; -}; +} parameter_list; /* * A sequence of asterisks and qualifiers, from right to left. For example,