From f3ec4bb41cddaeb154f0b8a7ffbc1d7d64691263 Mon Sep 17 00:00:00 2001 From: Luc Van Oostenryck Date: Mon, 27 Apr 2020 02:47:47 +0200 Subject: bad-goto: check declaration of label expressions Issue an error when taking the address of an undeclared label and mark the function as improper for linearization since the resulting IR would be invalid. Signed-off-by: Luc Van Oostenryck --- evaluate.c | 1 + validation/label-scope-cgoto.c | 1 - validation/linear/label-scope-cgoto.c | 1 - 3 files changed, 1 insertion(+), 2 deletions(-) diff --git a/evaluate.c b/evaluate.c index b272e3f6..63d75d90 100644 --- a/evaluate.c +++ b/evaluate.c @@ -3344,6 +3344,7 @@ struct symbol *evaluate_expression(struct expression *expr) case EXPR_LABEL: expr->ctype = &ptr_ctype; + check_label_declaration(expr->pos, expr->label_symbol); return &ptr_ctype; case EXPR_TYPE: diff --git a/validation/label-scope-cgoto.c b/validation/label-scope-cgoto.c index c5d278d3..1edb9948 100644 --- a/validation/label-scope-cgoto.c +++ b/validation/label-scope-cgoto.c @@ -65,7 +65,6 @@ l: 1; /* * check-name: label-scope-cgoto * check-command: sparse -Wno-decl $file - * check-known-to-fail * * check-error-start label-scope-cgoto.c:12:19: error: label 'l' used outside statement expression diff --git a/validation/linear/label-scope-cgoto.c b/validation/linear/label-scope-cgoto.c index 592f1ce4..0eba05ae 100644 --- a/validation/linear/label-scope-cgoto.c +++ b/validation/linear/label-scope-cgoto.c @@ -3,7 +3,6 @@ /* * check-name: linear/label-scope-cgoto * check-command: test-linearize -Wno-decl -I. $file - * check-known-to-fail * * check-error-ignore * check-output-ignore -- cgit 1.2.3-korg