Skip to contentSkip to conversation

expression: recognize references to labels as address constants

RFC PATCH Superseded Nicolai Stange 1 participant 1 message Jul 22, 2015 Sparse checker

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

RFC PATCH 8/13 expression: recognize references to labels as address constants

As an extension, GCC allows labels to be referenced a la
label1:
...

  void *ptr = &&label1;

Tag these label references as being address constants allowing them to be used as initializers for objects of static storage duration.

---
 expression.c | 2 ++
 1 file changed, 2 insertions(+)
expression.c +2 -0
index 4d5edc8..19786e8 100644
@@ -684,6 +684,8 @@ static struct token *unary_expression(struct token *token, struct expression **t
 				sym->ctype.modifiers |= MOD_ADDRESSABLE;
 				add_symbol(&function_computed_target_list, sym);
 			}
+			label->flags |=
+				expr_set_flag_mask(EXPR_FLAG_ADDR_CONST_EXPR);
 			label->label_symbol = sym;
 			*tree = label;
 			return token->next->next;
Signature · 1 line
2.4.5