Module Name: src Committed By: rillig Date: Wed Aug 2 21:58:12 UTC 2023
Modified Files: src/usr.bin/xlint/lint1: debug.c decl.c externs1.h Log Message: lint: remove unused string literals To generate a diff of this commit: cvs rdiff -u -r1.60 -r1.61 src/usr.bin/xlint/lint1/debug.c cvs rdiff -u -r1.376 -r1.377 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.206 -r1.207 src/usr.bin/xlint/lint1/externs1.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/debug.c diff -u src/usr.bin/xlint/lint1/debug.c:1.60 src/usr.bin/xlint/lint1/debug.c:1.61 --- src/usr.bin/xlint/lint1/debug.c:1.60 Wed Aug 2 18:51:25 2023 +++ src/usr.bin/xlint/lint1/debug.c Wed Aug 2 21:58:11 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: debug.c,v 1.60 2023/08/02 18:51:25 rillig Exp $ */ +/* $NetBSD: debug.c,v 1.61 2023/08/02 21:58:11 rillig Exp $ */ /*- * Copyright (c) 2021 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) -__RCSID("$NetBSD: debug.c,v 1.60 2023/08/02 18:51:25 rillig Exp $"); +__RCSID("$NetBSD: debug.c,v 1.61 2023/08/02 21:58:11 rillig Exp $"); #endif #include <stdlib.h> @@ -200,7 +200,7 @@ debug_node(const tnode_t *tn) // NOLINT( if (op == NAME) debug_printf(" '%s' with %s", tn->tn_sym->s_name, - storage_class_name(tn->tn_sym->s_scl)); + scl_name(tn->tn_sym->s_scl)); else debug_printf(" type"); debug_printf(" '%s'", type_name(tn->tn_type)); Index: src/usr.bin/xlint/lint1/decl.c diff -u src/usr.bin/xlint/lint1/decl.c:1.376 src/usr.bin/xlint/lint1/decl.c:1.377 --- src/usr.bin/xlint/lint1/decl.c:1.376 Wed Aug 2 21:26:12 2023 +++ src/usr.bin/xlint/lint1/decl.c Wed Aug 2 21:58:11 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.376 2023/08/02 21:26:12 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.377 2023/08/02 21:58: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.376 2023/08/02 21:26:12 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.377 2023/08/02 21:58:11 rillig Exp $"); #endif #include <sys/param.h> @@ -1297,6 +1297,14 @@ block_derive_function(type_t *ret, bool return tp; } +static const char * +tag_name(scl_t sc) +{ + return sc == STRUCT_TAG ? "struct" + : sc == UNION_TAG ? "union" + : "enum"; +} + static void check_prototype_parameters(sym_t *args) { @@ -1306,7 +1314,7 @@ check_prototype_parameters(sym_t *args) scl_t sc = sym->s_scl; if (sc == STRUCT_TAG || sc == UNION_TAG || sc == ENUM_TAG) { /* dubious tag declaration '%s %s' */ - warning(85, storage_class_name(sc), sym->s_name); + warning(85, tag_name(sc), sym->s_name); } } @@ -1546,13 +1554,12 @@ new_tag(sym_t *tag, scl_t scl, bool decl /* XXX: Why is this warning suppressed in C90 mode? */ if (allow_trad || allow_c99) /* declaration of '%s %s' intro... */ - warning(44, storage_class_name(scl), + warning(44, tag_name(scl), tag->s_name); tag = pushdown(tag); } else if (tag->s_scl != scl) { /* base type is really '%s %s' */ - warning(45, storage_class_name(tag->s_scl), - tag->s_name); + warning(45, tag_name(tag->s_scl), tag->s_name); } dcs->d_enclosing->d_nonempty_decl = true; } else if (decl) { @@ -1564,13 +1571,11 @@ new_tag(sym_t *tag, scl_t scl, bool decl dcs->d_enclosing->d_nonempty_decl = true; } else if (tag->s_scl != scl) { /* base type is really '%s %s' */ - warning(45, storage_class_name(tag->s_scl), - tag->s_name); + warning(45, tag_name(tag->s_scl), tag->s_name); /* XXX: Why is this warning suppressed in C90 mode? */ if (allow_trad || allow_c99) { /* declaration of '%s %s' introduces ... */ - warning(44, storage_class_name(scl), - tag->s_name); + warning(44, tag_name(scl), tag->s_name); } tag = pushdown(tag); dcs->d_enclosing->d_nonempty_decl = true; @@ -1579,8 +1584,8 @@ new_tag(sym_t *tag, scl_t scl, bool decl if (tag->s_scl != scl || (decl && !is_incomplete(tag->s_type))) { /* %s tag '%s' redeclared as %s */ - error(46, storage_class_name(tag->s_scl), - tag->s_name, storage_class_name(scl)); + error(46, tag_name(tag->s_scl), + tag->s_name, tag_name(scl)); print_previous_declaration(tag); tag = pushdown(tag); dcs->d_enclosing->d_nonempty_decl = true; @@ -1668,23 +1673,6 @@ make_tag_type(sym_t *tag, tspec_t kind, return tp; } -const char * -storage_class_name(scl_t sc) -{ - switch (sc) { - case EXTERN: return "extern"; - case STATIC: return "static"; - case AUTO: return "auto"; - case REG: return "register"; - case TYPEDEF: return "typedef"; - case STRUCT_TAG:return "struct"; - case UNION_TAG: return "union"; - case ENUM_TAG: return "enum"; - default: lint_assert(/*CONSTCOND*/false); - } - /* NOTREACHED */ -} - static bool has_named_member(const type_t *tp) { Index: src/usr.bin/xlint/lint1/externs1.h diff -u src/usr.bin/xlint/lint1/externs1.h:1.206 src/usr.bin/xlint/lint1/externs1.h:1.207 --- src/usr.bin/xlint/lint1/externs1.h:1.206 Wed Aug 2 21:11:35 2023 +++ src/usr.bin/xlint/lint1/externs1.h Wed Aug 2 21:58:11 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: externs1.h,v 1.206 2023/08/02 21:11:35 rillig Exp $ */ +/* $NetBSD: externs1.h,v 1.207 2023/08/02 21:58:11 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -238,7 +238,6 @@ void check_function_definition(sym_t *, sym_t *declarator_name(sym_t *); sym_t *old_style_function_parameter_name(sym_t *); type_t *make_tag_type(sym_t *, tspec_t, bool, bool); -const char *storage_class_name(scl_t); type_t *complete_struct_or_union(sym_t *); type_t *complete_enum(sym_t *); sym_t *enumeration_constant(sym_t *, int, bool);