add error for non-exter variadic functions

This commit is contained in:
Vexu
2020-04-17 22:02:49 +03:00
parent c026a9f6d2
commit 1afaf42525
3 changed files with 20 additions and 5 deletions

View File

@@ -3619,12 +3619,18 @@ static void add_top_level_decl(CodeGen *g, ScopeDecls *decls_scope, Tld *tld) {
assert(tld->source_node->type == NodeTypeFnProto);
is_export = tld->source_node->data.fn_proto.is_export;
if (!is_export && !tld->source_node->data.fn_proto.is_extern &&
if (!tld->source_node->data.fn_proto.is_extern &&
tld->source_node->data.fn_proto.fn_def_node == nullptr)
{
add_node_error(g, tld->source_node, buf_sprintf("non-extern function has no body"));
return;
}
if (!tld->source_node->data.fn_proto.is_extern &&
tld->source_node->data.fn_proto.is_var_args)
{
add_node_error(g, tld->source_node, buf_sprintf("non-extern function is variadic"));
return;
}
} else if (tld->id == TldIdUsingNamespace) {
g->resolve_queue.append(tld);
}