lint: extract main part of case_label into separate function
This commit is contained in:
parent
620f102450
commit
124253e8af
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: func.c,v 1.42 2021/01/01 10:55:28 rillig Exp $ */
|
||||
/* $NetBSD: func.c,v 1.43 2021/01/01 11:01:03 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.42 2021/01/01 10:55:28 rillig Exp $");
|
||||
__RCSID("$NetBSD: func.c,v 1.43 2021/01/01 11:01:03 rillig Exp $");
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
@ -413,34 +413,31 @@ named_label(sym_t *sym)
|
|||
reached = 1;
|
||||
}
|
||||
|
||||
void
|
||||
case_label(tnode_t *tn)
|
||||
static void
|
||||
check_case_label(tnode_t *tn, cstk_t *ci)
|
||||
{
|
||||
cstk_t *ci;
|
||||
clst_t *cl;
|
||||
val_t *v;
|
||||
val_t nv;
|
||||
tspec_t t;
|
||||
|
||||
/* find the stack entry for the innermost switch statement */
|
||||
for (ci = cstk; ci != NULL && !ci->c_switch; ci = ci->c_next)
|
||||
continue;
|
||||
|
||||
if (ci == NULL) {
|
||||
/* case not in switch */
|
||||
error(195);
|
||||
tn = NULL;
|
||||
} else if (tn != NULL && tn->tn_op != CON) {
|
||||
/* non-constant case expression */
|
||||
error(197);
|
||||
tn = NULL;
|
||||
} else if (tn != NULL && !tspec_is_int(tn->tn_type->t_tspec)) {
|
||||
/* non-integral case expression */
|
||||
error(198);
|
||||
tn = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
if (tn != NULL) {
|
||||
if (tn != NULL && tn->tn_op != CON) {
|
||||
/* non-constant case expression */
|
||||
error(197);
|
||||
return;
|
||||
}
|
||||
|
||||
if (tn != NULL && !tspec_is_int(tn->tn_type->t_tspec)) {
|
||||
/* non-integral case expression */
|
||||
error(198);
|
||||
return;
|
||||
}
|
||||
|
||||
lint_assert(ci->c_swtype != NULL);
|
||||
|
||||
|
@ -489,6 +486,18 @@ case_label(tnode_t *tn)
|
|||
ci->c_clst = cl;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
case_label(tnode_t *tn)
|
||||
{
|
||||
cstk_t *ci;
|
||||
|
||||
/* find the stack entry for the innermost switch statement */
|
||||
for (ci = cstk; ci != NULL && !ci->c_switch; ci = ci->c_next)
|
||||
continue;
|
||||
|
||||
check_case_label(tn, ci);
|
||||
|
||||
tfreeblk();
|
||||
|
||||
reached = 1;
|
||||
|
|
Loading…
Reference in New Issue