harec

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 75779e99755712e7582be3d69e91e608633d0e02
parent e0799f90f9926771a95fe9929364600be94a2569
Author: Eyal Sawady <ecs@d2evs.net>
Date:   Sun, 18 Apr 2021 11:57:29 -0400

Fix exported prototypes

Diffstat:
Msrc/check.c | 8++++----
Msrc/gen.c | 4++++
2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/check.c b/src/check.c @@ -2534,10 +2534,6 @@ static struct declaration * check_function(struct context *ctx, const struct ast_decl *adecl) { - if (!adecl->function.body) { - return NULL; // Prototype - } - const struct ast_function_decl *afndecl = &adecl->function; if ((adecl->function.flags & FN_TEST) && !tag_enabled(ctx->tags, "test")) { return NULL; @@ -2567,6 +2563,10 @@ check_function(struct context *ctx, } mkident(ctx, &decl->ident, &afndecl->ident); + if (!adecl->function.body) { + return decl; // Prototype + } + decl->func.scope = scope_push(&ctx->scope); struct ast_function_parameters *params = afndecl->prototype.params; while (params) { diff --git a/src/gen.c b/src/gen.c @@ -2895,6 +2895,10 @@ gen_function_decl(struct gen_context *ctx, const struct declaration *decl) assert(decl->type == DECL_FUNC); const struct function_decl *func = &decl->func; const struct type *fntype = func->type; + + if (func->body == NULL) { + return; // Prototype + } struct qbe_def *qdef = xcalloc(1, sizeof(struct qbe_def)); qdef->kind = Q_FUNC;