Module Name: src
Committed By: christos
Date: Mon Nov 1 13:30:11 UTC 2021
Modified Files:
src/usr.bin/xlint/lint1: tree.c
Log Message:
simplify.
To generate a diff of this commit:
cvs rdiff -u -r1.389 -r1.390 src/usr.bin/xlint/lint1/tree.c
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/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.389 src/usr.bin/xlint/lint1/tree.c:1.390
--- src/usr.bin/xlint/lint1/tree.c:1.389 Mon Nov 1 07:46:50 2021
+++ src/usr.bin/xlint/lint1/tree.c Mon Nov 1 09:30:11 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: tree.c,v 1.389 2021/11/01 11:46:50 rillig Exp $ */
+/* $NetBSD: tree.c,v 1.390 2021/11/01 13:30:11 christos Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.389 2021/11/01 11:46:50 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.390 2021/11/01 13:30:11 christos Exp $");
#endif
#include <float.h>
@@ -1779,23 +1779,23 @@ check_enum_array_index(const tnode_t *ln
int max_array_index;
int64_t max_enum_value;
const struct sym *ec, *max_ec;
+ const type_t *lt, *rt;
- if (ln->tn_op != ADDR)
- return;
- if (ln->tn_left->tn_op != NAME)
- return;
- if (ln->tn_left->tn_type->t_tspec != ARRAY)
+ if (ln->tn_op != ADDR || ln->tn_left->tn_op != NAME)
return;
- if (ln->tn_left->tn_type->t_incomplete_array)
- return;
- if (rn->tn_op != CVT)
+
+ lt = ln->tn_left->tn_type;
+ if (lt->t_tspec != ARRAY || lt->t_incomplete_array)
return;
- if (rn->tn_left->tn_op != LOAD)
+
+ if (rn->tn_op != CVT || rn->tn_left->tn_op != LOAD)
return;
- if (rn->tn_left->tn_type->t_tspec != ENUM)
+
+ rt = rn->tn_left->tn_type;
+ if (rt->t_tspec != ENUM)
return;
- ec = rn->tn_left->tn_type->t_enum->en_first_enumerator;
+ ec = rt->t_enum->en_first_enumerator;
max_ec = ec;
lint_assert(ec != NULL);
for (ec = ec->s_next; ec != NULL; ec = ec->s_next)
@@ -1805,7 +1805,7 @@ check_enum_array_index(const tnode_t *ln
max_enum_value = max_ec->s_value.v_quad;
lint_assert(INT_MIN <= max_enum_value && max_enum_value <= INT_MAX);
- max_array_index = ln->tn_left->tn_type->t_dim - 1;
+ max_array_index = lt->t_dim - 1;
if (max_enum_value == max_array_index)
return;
@@ -1820,8 +1820,7 @@ check_enum_array_index(const tnode_t *ln
return;
/* maximum value %d of '%s' does not match maximum array index %d */
- warning(348, (int)max_enum_value, type_name(rn->tn_left->tn_type),
- max_array_index);
+ warning(348, (int)max_enum_value, type_name(rt), max_array_index);
print_previous_declaration(-1, max_ec);
}