Reorganize the code to not repeat the test of the label's namespace. Also, make all namespaces other than NS_LABEL & NS_ITERATOR as bogus and add some comments. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> --- evaluate.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/evaluate.c b/evaluate.c index 2b845a301d6b..663540ff6445 100644 --- a/evaluate.c +++ b/evaluate.c @@ -3748,20 +3748,22 @@ static void evaluate_goto_statement(struct statement *stmt) return; } - if (label->namespace == NS_LABEL && !label->stmt) { - sparse_error(stmt->pos, "label '%s' was not declared", show_ident(label->ident)); - current_fn->bogus_linear = 1; - } - if (label->namespace == NS_LABEL && label->stmt) { - if (is_in_scope(label->label_scope, stmt->goto_scope)) - return; - sparse_error(stmt->pos, "goto into statement expression"); - info(label->stmt->pos," label '%s' is defined here", - show_ident(label->ident)); + switch (label->namespace) { + case NS_ITERATOR: // break / continue + break; + case NS_LABEL: // goto + ident + if (!label->stmt) { + sparse_error(stmt->pos, "label '%s' was not declared", + show_ident(label->ident)); + } else if (!is_in_scope(label->label_scope, stmt->goto_scope)) { + sparse_error(stmt->pos, "goto into statement expression"); + info(label->stmt->pos," label '%s' is defined here", + show_ident(label->ident)); + } else + break; + default: current_fn->bogus_linear = 1; } - if (label->namespace == NS_NONE) - current_fn->bogus_linear = 1; } struct symbol *evaluate_statement(struct statement *stmt) -- 2.26.0