aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-04-26 22:45:06 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-05-21 17:27:45 +0200
commit25216452d77c39fcb258ff96d44f4f8d55bbda43 (patch)
tree0259ee789bd064bc1b971cf614f76e4a73ab7ee1
parent33319e351c2874ca7c187bd96e7d986794fd2b41 (diff)
downloadsparse-25216452d77c39fcb258ff96d44f4f8d55bbda43.tar.gz
bad-goto: label expression inside a statement expression is UB
More exactly, what is undefined is to jump inside the statement expression with a computed goto. Of course, once the address of such a label is taken, it's generaly impossible to track if it will be used or not to jump inside the statement expression. So, for now, handle taking the address of such a label from outside the statement expression, exactly as if a computed goto is effectively done from there and so issue an error message and also mark the function as useless for linearization. Note: this is only partially correct since: 1) the address could be taken from outside the statement and never used for a computed goto. 2) the address could be taken from outside the statement but the corresponding computed goto only done from inside, which is perfectly fine. 3) the address could be taken from inside but a computed goto done from outside. Note: the real problem, like for the regular goto, is that the statement expression can be eliminated before linearization, the correspondng gotos corresponding then to branches to unexistent BBs. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--expression.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/expression.c b/expression.c
index f8a8f03e..bbbc24e6 100644
--- a/expression.c
+++ b/expression.c
@@ -691,6 +691,7 @@ static struct token *unary_expression(struct token *token, struct expression **t
sym->ctype.modifiers |= MOD_ADDRESSABLE;
add_symbol(&function_computed_target_list, sym);
}
+ check_label_usage(sym, token->pos);
label->flags = CEF_ADDR;
label->label_symbol = sym;
*tree = label;