mirror of
https://github.com/odin-lang/Odin.git
synced 2026-08-26 06:51:34 +00:00
Add warning for unused lables in asm templates
This commit is contained in:
@@ -1502,6 +1502,9 @@ gb_internal void check_asm_instruction_operand(AsmCtx *asm_ctx, CheckerContext *
|
||||
error(expr, "Undeclared asm label '.%.*s'", LIT(name->token.string));
|
||||
}
|
||||
name->entity = found;
|
||||
if (found != nullptr) {
|
||||
found->flags |= EntityFlag_Used;
|
||||
}
|
||||
|
||||
add_type_and_value(ctx, expr, Addressing_Value, found->type, {});
|
||||
return;
|
||||
@@ -1844,6 +1847,14 @@ gb_internal void check_asm_template(AsmCtx *asm_ctx, CheckerContext *ctx, Entity
|
||||
}
|
||||
}
|
||||
|
||||
for (auto const &entry : ate->label_scope->elements) {
|
||||
Entity *le = entry.value;
|
||||
GB_ASSERT(le != nullptr);
|
||||
if ((le->flags & EntityFlag_Used) == 0) {
|
||||
warning(le->token, "'asm' label '.%.*s' is declared but never reference by any instruction", LIT(le->token.string));
|
||||
}
|
||||
}
|
||||
|
||||
GB_ASSERT(entity->kind == Entity_AsmTemplate);
|
||||
if (results->Tuple.variables.count == 0 && !entity->AsmTemplate.is_volatile &&
|
||||
!entity->AsmTemplate.clobber_memory &&
|
||||
|
||||
Reference in New Issue
Block a user