Mon Jan 4 22:33:47 2021 UTC ()
lint: replace LERROR with lint_assert in check_expr_misc

This reduces the visual clutter.  There is no reason for anyone to
modify the code around the CALL operator, therefore the assertion is not
expected to fail anytime soon.


(rillig)
diff -r1.127 -r1.128 src/usr.bin/xlint/lint1/tree.c

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

--- src/usr.bin/xlint/lint1/tree.c 2021/01/04 22:26:50 1.127
+++ src/usr.bin/xlint/lint1/tree.c 2021/01/04 22:33:47 1.128
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: tree.c,v 1.127 2021/01/04 22:26:50 rillig Exp $ */ 1/* $NetBSD: tree.c,v 1.128 2021/01/04 22:33:47 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.127 2021/01/04 22:26:50 rillig Exp $"); 40__RCSID("$NetBSD: tree.c,v 1.128 2021/01/04 22:33:47 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 *new_integer_constant_node(tspec_t, int64_t); 53static tnode_t *new_integer_constant_node(tspec_t, int64_t);
@@ -3636,30 +3636,28 @@ check_expr_misc(tnode_t *tn, int vctx, i @@ -3636,30 +3636,28 @@ check_expr_misc(tnode_t *tn, int vctx, i
3636 } 3636 }
3637 break; 3637 break;
3638 case ASSIGN: 3638 case ASSIGN:
3639 if (ln->tn_op == NAME && !szof && (reached || rchflg)) { 3639 if (ln->tn_op == NAME && !szof && (reached || rchflg)) {
3640 mark_as_set(ln->tn_sym); 3640 mark_as_set(ln->tn_sym);
3641 if (ln->tn_sym->s_scl == EXTERN) 3641 if (ln->tn_sym->s_scl == EXTERN)
3642 outusg(ln->tn_sym); 3642 outusg(ln->tn_sym);
3643 } 3643 }
3644 if (ln->tn_op == STAR && ln->tn_left->tn_op == PLUS) 3644 if (ln->tn_op == STAR && ln->tn_left->tn_op == PLUS)
3645 /* check the range of array indices */ 3645 /* check the range of array indices */
3646 check_array_index(ln->tn_left, 0); 3646 check_array_index(ln->tn_left, 0);
3647 break; 3647 break;
3648 case CALL: 3648 case CALL:
3649 if (ln->tn_op != AMPER || ln->tn_left->tn_op != NAME) 3649 lint_assert(ln->tn_op == AMPER);
3650 LERROR("check_expr_misc(op=%s != %s || %s != %s)", 3650 lint_assert(ln->tn_left->tn_op == NAME);
3651 getopname(ln->tn_op), getopname(AMPER), 
3652 getopname(ln->tn_left->tn_op), getopname(NAME)); 
3653 if (!szof) 3651 if (!szof)
3654 outcall(tn, vctx || tctx, rvdisc); 3652 outcall(tn, vctx || tctx, rvdisc);
3655 break; 3653 break;
3656 case EQ: 3654 case EQ:
3657 if (hflag && eqwarn) 3655 if (hflag && eqwarn)
3658 /* operator '==' found where '=' was expected */ 3656 /* operator '==' found where '=' was expected */
3659 warning(160); 3657 warning(160);
3660 break; 3658 break;
3661 case CON: 3659 case CON:
3662 case NAME: 3660 case NAME:
3663 case STRING: 3661 case STRING:
3664 return; 3662 return;
3665 /* LINTED206: (enumeration values not handled in switch) */ 3663 /* LINTED206: (enumeration values not handled in switch) */