harec

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

commit 69dc9dd9819765dd1f1cf34b1b84197aa10feb78
parent 8b9ba5c36380ea10047e4384ff03703d939dbc68
Author: Drew DeVault <sir@cmpwn.com>
Date:   Thu, 23 Dec 2021 14:07:06 +0100

check: handle contextual array constants

Signed-off-by: Drew DeVault <sir@cmpwn.com>

Diffstat:
Msrc/check.c | 8++++++++
1 file changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/check.c b/src/check.c @@ -3268,6 +3268,14 @@ scan_const(struct context *ctx, const struct ast_global_decl *decl) struct expression *initializer = xcalloc(1, sizeof(struct expression)); check_expression(ctx, decl->init, initializer, type); + bool context = decl->type + && decl->type->storage == STORAGE_ARRAY + && decl->type->array.contextual; + if (context) { + // XXX: Do we need to do anything more here + type = initializer->result; + } + expect(&decl->init->loc, type_is_assignable(type, initializer->result), "Constant type is not assignable from initializer type"); initializer = lower_implicit_cast(type, initializer);