@@ -2379,6 +2379,7 @@ static pseudo_t linearize_statement(struct entrypoint *ep, struct statement *stm
}
case STMT_GOTO: {
+ struct symbol *label;
struct symbol *sym;
struct expression *expr;
struct instruction *goto_ins;
@@ -2389,8 +2390,16 @@ static pseudo_t linearize_statement(struct entrypoint *ep, struct statement *stm
if (!bb_reachable(active))
break;
- if (stmt->goto_label) {
- add_goto(ep, get_bound_block(ep, stmt->goto_label));
+ label = stmt->goto_label;
+ if (label) {
+ if (!label->stmt) {
+ // do not issue a branch to non-existent labels
+ if (label->namespace == NS_LABEL)
+ break;
+ if (label->namespace == NS_NONE)
+ break;
+ }
+ add_goto(ep, get_bound_block(ep, label));
break;
}
@@ -11,7 +11,6 @@ void bar(void)
/*
* check-name: invalid-labels0
* check-command: test-linearize -Wno-decl $file
- * check-known-to-fail
*
* check-output-ignore
* check-output-excludes: END
If the label doesn't exist, the corresponding BB will never be created and the CFG will be invalid. So, do not issue the branch for goto to these labels. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> --- linearize.c | 13 +++++++++++-- validation/linear/invalid-labels0.c | 1 - 2 files changed, 11 insertions(+), 3 deletions(-)