aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-04-12 10:37:58 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-05-21 17:27:45 +0200
commit86edd142e6fa4483cf5cb057ffac4cb548a9374c (patch)
treeabcb73adc2efa9f2755d2ef820528b9d2975c76c
parent4a71ea1810242c08f66afe16ef9ec0b917439023 (diff)
downloadsparse-86edd142e6fa4483cf5cb057ffac4cb548a9374c.tar.gz
bad-goto: simplify testing of undeclared labels
There is no need to do a lookup: checking if the label's symbol is in the NS_LABEL namespace and is lacking an associated statement is enough and much simpler. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--evaluate.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/evaluate.c b/evaluate.c
index 4bdd5ed0..d4b46227 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -3747,7 +3747,8 @@ static void evaluate_goto_statement(struct statement *stmt)
evaluate_expression(stmt->goto_expression);
return;
}
- if (!label->stmt && label->ident && !lookup_keyword(label->ident, NS_KEYWORD)) {
+
+ if (label->namespace == NS_LABEL && !label->stmt) {
sparse_error(stmt->pos, "label '%s' was not declared", show_ident(label->ident));
}
}