mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 07:38:48 +00:00
Add extra check for bodiless procedures
This commit is contained in:
@@ -362,6 +362,8 @@ void check_proc_decl(Checker *c, Entity *e, DeclInfo *d) {
|
|||||||
|
|
||||||
GB_ASSERT(pd->body->kind == AstNode_BlockStmt);
|
GB_ASSERT(pd->body->kind == AstNode_BlockStmt);
|
||||||
check_procedure_later(c, c->curr_ast_file, e->token, d, proc_type, pd->body, pd->tags);
|
check_procedure_later(c, c->curr_ast_file, e->token, d, proc_type, pd->body, pd->tags);
|
||||||
|
} else if (!is_foreign) {
|
||||||
|
error(e->token, "Only a foreign procedure cannot have a body");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pt->result_count == 0 && is_require_results) {
|
if (pt->result_count == 0 && is_require_results) {
|
||||||
|
|||||||
+2
-7
@@ -1696,19 +1696,14 @@ void check_collect_entities(Checker *c, Array<AstNode *> nodes, bool is_file_sco
|
|||||||
|
|
||||||
case_ast_node(fb, ForeignBlockDecl, decl);
|
case_ast_node(fb, ForeignBlockDecl, decl);
|
||||||
AstNode *foreign_library = fb->foreign_library;
|
AstNode *foreign_library = fb->foreign_library;
|
||||||
bool ok = true;
|
|
||||||
if (foreign_library->kind != AstNode_Ident) {
|
if (foreign_library->kind != AstNode_Ident) {
|
||||||
error_node(foreign_library, "foreign library name must be an identifier");
|
error_node(foreign_library, "foreign library name must be an identifier");
|
||||||
ok = false;
|
foreign_library = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckerContext prev_context = c->context;
|
CheckerContext prev_context = c->context;
|
||||||
if (ok) {
|
c->context.curr_foreign_library = foreign_library;
|
||||||
c->context.curr_foreign_library = foreign_library;
|
|
||||||
}
|
|
||||||
|
|
||||||
check_collect_entities(c, fb->decls, is_file_scope);
|
check_collect_entities(c, fb->decls, is_file_scope);
|
||||||
|
|
||||||
c->context = prev_context;
|
c->context = prev_context;
|
||||||
case_end;
|
case_end;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user