Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/xlint/lint1 lint: rename members of struct control_s...
details: https://anonhg.NetBSD.org/src/rev/55b54e537350
branches: trunk
changeset: 960690:55b54e537350
user: rillig <rillig%NetBSD.org@localhost>
date: Fri Mar 26 19:17:58 2021 +0000
description:
lint: rename members of struct control_statement to be more expressive
C99 does not define names for the head parts of the 'for' statements, it
just calls them clause-1, expression-2 and expression-3. Therefore the
rather abstract name 'expr3'.
No functional change.
diffstat:
usr.bin/xlint/lint1/func.c | 47 ++++++++++++++++++++++----------------------
usr.bin/xlint/lint1/lint1.h | 30 ++++++++++++++++------------
2 files changed, 41 insertions(+), 36 deletions(-)
diffs (189 lines):
diff -r 4548a7d808f2 -r 55b54e537350 usr.bin/xlint/lint1/func.c
--- a/usr.bin/xlint/lint1/func.c Fri Mar 26 18:54:39 2021 +0000
+++ b/usr.bin/xlint/lint1/func.c Fri Mar 26 19:17:58 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: func.c,v 1.96 2021/03/26 18:54:39 rillig Exp $ */
+/* $NetBSD: func.c,v 1.97 2021/03/26 19:17:58 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: func.c,v 1.96 2021/03/26 18:54:39 rillig Exp $");
+__RCSID("$NetBSD: func.c,v 1.97 2021/03/26 19:17:58 rillig Exp $");
#endif
#include <stdlib.h>
@@ -183,7 +183,7 @@
free(cl);
}
- free(ci->c_swtype);
+ free(ci->c_switch_type);
free(ci);
}
@@ -439,15 +439,15 @@
{
/* similar to typeok_enum in tree.c */
- if (!(tn->tn_type->t_is_enum || ci->c_swtype->t_is_enum))
+ if (!(tn->tn_type->t_is_enum || ci->c_switch_type->t_is_enum))
return;
- if (tn->tn_type->t_is_enum && ci->c_swtype->t_is_enum &&
- tn->tn_type->t_enum == ci->c_swtype->t_enum)
+ if (tn->tn_type->t_is_enum && ci->c_switch_type->t_is_enum &&
+ tn->tn_type->t_enum == ci->c_switch_type->t_enum)
return;
#if 0 /* not yet ready, see msg_130.c */
/* enum type mismatch: '%s' '%s' '%s' */
- warning(130, type_name(ci->c_swtype), getopname(EQ),
+ warning(130, type_name(ci->c_switch_type), getopname(EQ),
type_name(tn->tn_type));
#endif
}
@@ -480,7 +480,7 @@
check_case_label_enum(tn, ci);
- lint_assert(ci->c_swtype != NULL);
+ lint_assert(ci->c_switch_type != NULL);
if (reached && !seen_fallthrough) {
if (hflag)
@@ -502,7 +502,7 @@
*/
v = constant(tn, true);
(void)memset(&nv, 0, sizeof nv);
- convert_constant(CASE, 0, ci->c_swtype, &nv, v);
+ convert_constant(CASE, 0, ci->c_switch_type, &nv, v);
free(v);
/* look if we had this value already */
@@ -697,7 +697,7 @@
begin_control_statement(CS_SWITCH);
cstmt->c_switch = true;
- cstmt->c_swtype = tp;
+ cstmt->c_switch_type = tp;
set_reached(false);
seen_fallthrough = true;
@@ -713,17 +713,17 @@
sym_t *esym;
case_label_t *cl;
- lint_assert(cstmt->c_swtype != NULL);
+ lint_assert(cstmt->c_switch_type != NULL);
/*
* If the switch expression was of type enumeration, count the case
* labels and the number of enumerators. If both counts are not
* equal print a warning.
*/
- if (cstmt->c_swtype->t_is_enum) {
+ if (cstmt->c_switch_type->t_is_enum) {
nenum = nclab = 0;
- lint_assert(cstmt->c_swtype->t_enum != NULL);
- for (esym = cstmt->c_swtype->t_enum->en_first_enumerator;
+ lint_assert(cstmt->c_switch_type->t_enum != NULL);
+ for (esym = cstmt->c_switch_type->t_enum->en_first_enumerator;
esym != NULL; esym = esym->s_next) {
nenum++;
}
@@ -744,7 +744,8 @@
*/
set_reached(true);
} else if (!cstmt->c_default &&
- (!hflag || !cstmt->c_swtype->t_is_enum || nenum != nclab)) {
+ (!hflag || !cstmt->c_switch_type->t_is_enum ||
+ nenum != nclab)) {
/*
* there are possible values which are not handled in
* switch
@@ -882,10 +883,10 @@
* Also remember this expression itself. We must check it at
* the end of the loop to get "used but not set" warnings correct.
*/
- cstmt->c_fexprm = tsave();
- cstmt->c_f3expr = tn3;
- cstmt->c_fpos = curr_pos;
- cstmt->c_cfpos = csrc_pos;
+ cstmt->c_for_expr3_mem = tsave();
+ cstmt->c_for_expr3 = tn3;
+ cstmt->c_for_expr3_pos = curr_pos;
+ cstmt->c_for_expr3_csrc_pos = csrc_pos;
if (tn1 != NULL)
expr(tn1, false, false, true, false);
@@ -919,10 +920,10 @@
cspos = csrc_pos;
/* Restore the tree memory for the reinitialization expression */
- trestor(cstmt->c_fexprm);
- tn3 = cstmt->c_f3expr;
- curr_pos = cstmt->c_fpos;
- csrc_pos = cstmt->c_cfpos;
+ trestor(cstmt->c_for_expr3_mem);
+ tn3 = cstmt->c_for_expr3;
+ curr_pos = cstmt->c_for_expr3_pos;
+ csrc_pos = cstmt->c_for_expr3_csrc_pos;
/* simply "statement not reached" would be confusing */
if (!reached && warn_about_unreachable) {
diff -r 4548a7d808f2 -r 55b54e537350 usr.bin/xlint/lint1/lint1.h
--- a/usr.bin/xlint/lint1/lint1.h Fri Mar 26 18:54:39 2021 +0000
+++ b/usr.bin/xlint/lint1/lint1.h Fri Mar 26 19:17:58 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lint1.h,v 1.88 2021/03/26 18:54:39 rillig Exp $ */
+/* $NetBSD: lint1.h,v 1.89 2021/03/26 19:17:58 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -392,12 +392,13 @@
*/
typedef struct control_statement {
control_statement_kind c_kind; /* to ensure proper nesting */
- bool c_loop : 1; /* continue && break are valid */
- bool c_switch : 1; /* case && break are valid */
+ bool c_loop : 1; /* 'continue' and 'break' are valid */
+ bool c_switch : 1; /* 'case' and 'break' are valid */
bool c_break : 1; /* the loop/switch has a reachable
- * break statement */
- bool c_continue : 1; /* loop has continue */
- bool c_default : 1; /* switch has default */
+ * 'break' statement */
+ bool c_continue : 1; /* the loop has a reachable 'continue'
+ * statement */
+ bool c_default : 1; /* the switch has a 'default' label */
bool c_maybe_endless : 1; /* the controlling expression is
* always true (as in 'for (;;)' or
* 'while (1)'), there may be break
@@ -405,14 +406,17 @@
bool c_always_then : 1;
bool c_reached_end_of_then : 1;
bool c_had_return_noval : 1; /* had "return;" */
- bool c_had_return_value : 1; /* had "return (e);" */
- type_t *c_swtype; /* type of switch expression */
+ bool c_had_return_value : 1; /* had "return expr;" */
+
+ type_t *c_switch_type; /* type of switch expression */
case_label_t *c_case_labels; /* list of case values */
- struct mbl *c_fexprm; /* saved memory for end of loop
- expression in for() */
- tnode_t *c_f3expr; /* end of loop expr in for() */
- pos_t c_fpos; /* position of end of loop expr */
- pos_t c_cfpos; /* same for csrc_pos */
+
+ struct mbl *c_for_expr3_mem; /* saved memory for end of loop
+ * expression in for() */
+ tnode_t *c_for_expr3; /* end of loop expr in for() */
+ pos_t c_for_expr3_pos; /* position of end of loop expr */
+ pos_t c_for_expr3_csrc_pos; /* same for csrc_pos */
+
struct control_statement *c_surrounding;
} cstk_t;
Home |
Main Index |
Thread Index |
Old Index