From 38e7c70c3074caab4c5aa68c0cee299a71537bee Mon Sep 17 00:00:00 2001 From: Luc Van Oostenryck Date: Sat, 11 Apr 2020 12:11:17 +0200 Subject: bad-goto: catch labels with reserved names If a reserved name is used as the destination of a goto, its associated label won't be valid and at linearization time no BB will can be created for it, resulting in an invalid IR. So, catch such gotos at evaluation time and mark the function to not be linearized. Signed-off-by: Luc Van Oostenryck --- evaluate.c | 2 ++ validation/linear/goto-invalid.c | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/evaluate.c b/evaluate.c index c757fc82..21d5d761 100644 --- a/evaluate.c +++ b/evaluate.c @@ -3752,6 +3752,8 @@ static void evaluate_goto_statement(struct statement *stmt) sparse_error(stmt->pos, "label '%s' was not declared", show_ident(label->ident)); current_fn->bogus_linear = 1; } + if (label->namespace == NS_NONE) + current_fn->bogus_linear = 1; } struct symbol *evaluate_statement(struct statement *stmt) diff --git a/validation/linear/goto-invalid.c b/validation/linear/goto-invalid.c index 569d0b0d..860b32a4 100644 --- a/validation/linear/goto-invalid.c +++ b/validation/linear/goto-invalid.c @@ -11,7 +11,6 @@ void bar(void) /* * check-name: goto-invalid * check-command: test-linearize -Wno-decl $file - * check-known-to-fail * * check-error-ignore * check-output-ignore -- cgit 1.2.3-korg