harec

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

commit 58c35c5ebf2e4ab6d8a73311b40292036d407827
parent fb63ef040c48ff03b4b04863c5ad75ba37c2f7fa
Author: Bor Grošelj Simić <bor.groseljsimic@telemach.net>
Date:   Wed, 16 Feb 2022 01:32:07 +0100

check: handle multiple type declarations in a single list

Previously only the first declaration was processed and all the others were
skipped.

Signed-off-by: Bor Grošelj Simić <bor.groseljsimic@telemach.net>

Diffstat:
Msrc/check.c | 24+++++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/src/check.c b/src/check.c @@ -3074,23 +3074,24 @@ check_global(struct context *ctx, static struct declaration * check_type(struct context *ctx, - const struct ast_decl *adecl) + const struct ast_type_decl *adecl, + bool exported) { struct declaration *decl = xcalloc(1, sizeof(struct declaration)); - if (!adecl->type.ident.ns) { - mkident(ctx, &decl->ident, &adecl->type.ident); + if (!adecl->ident.ns) { + mkident(ctx, &decl->ident, &adecl->ident); } else { - decl->ident = adecl->type.ident; + decl->ident = adecl->ident; } decl->type = DECL_TYPE; const struct type *type = - type_store_lookup_atype(ctx->store, adecl->type.type); + type_store_lookup_atype(ctx->store, adecl->type); struct type _alias = { .storage = STORAGE_ALIAS, .alias = { .ident = decl->ident, .type = type, - .exported = adecl->exported, + .exported = exported, }, .size = type->size, .align = type->align, @@ -3142,7 +3143,16 @@ check_declarations(struct context *ctx, decl = NULL; break; case AST_DECL_TYPE: - decl = check_type(ctx, adecl); + for (const struct ast_type_decl *t = &adecl->type; + t; t = t->next) { + decl = check_type(ctx, t, adecl->exported); + struct declarations *decls = *next = + xcalloc(1, sizeof(struct declarations)); + decl->exported = adecl->exported; + decls->decl = decl; + next = &decls->next; + } + decl = NULL; break; }