aboutsummaryrefslogtreecommitdiff
path: root/src/check_expr.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2020-06-10 15:37:50 +0100
committergingerBill <bill@gingerbill.org>2020-06-10 15:37:50 +0100
commit57b09b2ffbd1021d29e43fdc1f27da43f1b4ed23 (patch)
treeace60d87ae2fc67f35267ac954a58f1b2b91b711 /src/check_expr.cpp
parente86fde3cb16d2977054aa727c32cd4efcb1bd8a7 (diff)
Fix #439
Diffstat (limited to 'src/check_expr.cpp')
-rw-r--r--src/check_expr.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index a52295298..059ed917d 100644
--- a/src/check_expr.cpp
+++ b/src/check_expr.cpp
@@ -7760,6 +7760,20 @@ bool check_range(CheckerContext *c, Ast *node, Operand *x, Operand *y, ExactValu
return true;
}
+bool check_is_operand_compound_lit_constant(CheckerContext *c, Operand *o) {
+ Ast *expr = unparen_expr(o->expr);
+ if (expr != nullptr) {
+ Entity *e = strip_entity_wrapping(entity_from_expr(expr));
+ if (e != nullptr && e->kind == Entity_Procedure) {
+ return true;
+ }
+ if (expr->kind == Ast_ProcLit) {
+ add_type_and_value(c->info, expr, Addressing_Constant, type_of_expr(expr), exact_value_procedure(expr));
+ return true;
+ }
+ }
+ return o->mode == Addressing_Constant;
+}
ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type *type_hint) {
@@ -7780,7 +7794,6 @@ ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type
c->state_flags = out;
}
-
ExprKind kind = Expr_Stmt;
o->mode = Addressing_Invalid;
@@ -8242,7 +8255,7 @@ ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type
is_constant = false;
}
if (is_constant) {
- is_constant = o.mode == Addressing_Constant;
+ is_constant = check_is_operand_compound_lit_constant(c, &o);
}
check_assignment(c, &o, field->type, str_lit("structure literal"));
@@ -8277,7 +8290,7 @@ ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type
is_constant = false;
}
if (is_constant) {
- is_constant = o.mode == Addressing_Constant;
+ is_constant = check_is_operand_compound_lit_constant(c, &o);
}
check_assignment(c, &o, field->type, str_lit("structure literal"));