stage1: Make the parser reject extern fn with body

This commit is contained in:
LemonBoy
2020-02-18 22:53:03 +01:00
committed by Andrew Kelley
parent 95a71e29f8
commit a6b74cdd38
2 changed files with 11 additions and 0 deletions

View File

@@ -689,6 +689,9 @@ static AstNode *ast_parse_top_level_decl(ParseContext *pc, VisibMod visib_mod, B
AstNode *res = fn_proto;
if (body != nullptr) {
if (fn_proto->data.fn_proto.is_extern) {
ast_error(pc, first, "Extern functions have no body");
}
res = ast_create_node_copy_line_info(pc, NodeTypeFnDef, fn_proto);
res->data.fn_def.fn_proto = fn_proto;
res->data.fn_def.body = body;