| ... | ... | @@ -471,6 +471,7 @@ static TypeTableEntry * analyze_expression(CodeGen *g, ImportTableEntry *import, |
| 471 | 471 | assert(!node->codegen_node); |
| 472 | 472 | node->codegen_node = allocate<CodeGenNode>(1); |
| 473 | 473 | node->codegen_node->data.label_entry = table_entry->value; |
| 474 | table_entry->value->used = true; |
| 474 | 475 | } else { |
| 475 | 476 | add_node_error(g, node, |
| 476 | 477 | buf_sprintf("use of undeclared label '%s'", buf_ptr(&node->data.go_to.name))); |
| ... | ... | @@ -758,6 +759,23 @@ static void analyze_top_level_declaration(CodeGen *g, ImportTableEntry *import, |
| 758 | 759 | node->codegen_node = allocate<CodeGenNode>(1); |
| 759 | 760 | node->codegen_node->data.fn_def_node.implicit_return_type = block_return_type; |
| 760 | 761 | node->codegen_node->data.fn_def_node.block_context = context; |
| 762 | |
| 763 | { |
| 764 | FnTableEntry *fn_table_entry = fn_proto_node->codegen_node->data.fn_proto_node.fn_table_entry; |
| 765 | auto it = fn_table_entry->label_table.entry_iterator(); |
| 766 | for (;;) { |
| 767 | auto *entry = it.next(); |
| 768 | if (!entry) |
| 769 | break; |
| 770 | |
| 771 | LabelTableEntry *label_entry = entry->value; |
| 772 | if (!label_entry->used) { |
| 773 | add_node_error(g, label_entry->label_node, |
| 774 | buf_sprintf("label '%s' defined but not used", |
| 775 | buf_ptr(&label_entry->label_node->data.label.name))); |
| 776 | } |
| 777 | } |
| 778 | } |
| 761 | 779 | } |
| 762 | 780 | break; |
| 763 | 781 | |