aboutsummaryrefslogtreecommitdiff
path: root/src/check_expr.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2020-02-23 10:39:57 +0000
committergingerBill <bill@gingerbill.org>2020-02-23 10:39:57 +0000
commite197af766d5ead2a1a67ead4c780848c6749a5b1 (patch)
treea874c73d31366c8fdcccd7546e4294d5df51a6d6 /src/check_expr.cpp
parent2180f4a475287546b9230745343ca3e0847525c6 (diff)
parent10fe5e97b3eea5409660220a903bc6ad09478c1b (diff)
Merge branch 'master' into llvm-integration
Diffstat (limited to 'src/check_expr.cpp')
-rw-r--r--src/check_expr.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index 6d049747f..cf9e42810 100644
--- a/src/check_expr.cpp
+++ b/src/check_expr.cpp
@@ -2260,6 +2260,8 @@ bool check_cast_internal(CheckerContext *c, Operand *x, Type *type) {
x->mode = Addressing_Value;
} else if (is_type_slice(type) && is_type_string(x->type)) {
x->mode = Addressing_Value;
+ } else if (is_type_union(type)) {
+ x->mode = Addressing_Value;
}
return true;
}
@@ -5942,7 +5944,9 @@ CALL_ARGUMENT_CHECKER(check_call_arguments_internal) {
Entity *e = sig_params[operand_index];
Type *t = e->type;
Operand o = operands[operand_index];
- call->viral_state_flags |= o.expr->viral_state_flags;
+ if (o.expr != nullptr) {
+ call->viral_state_flags |= o.expr->viral_state_flags;
+ }
if (e->kind == Entity_TypeName) {
// GB_ASSERT(!variadic);
@@ -6296,7 +6300,7 @@ Entity **populate_proc_parameter_list(CheckerContext *c, Type *proc_type, isize
}
-bool evaluate_where_clauses(CheckerContext *ctx, Scope *scope, Array<Ast *> *clauses, bool print_err) {
+bool evaluate_where_clauses(CheckerContext *ctx, Ast *call_expr, Scope *scope, Array<Ast *> *clauses, bool print_err) {
if (clauses != nullptr) {
for_array(i, *clauses) {
Ast *clause = (*clauses)[i];
@@ -6304,9 +6308,11 @@ bool evaluate_where_clauses(CheckerContext *ctx, Scope *scope, Array<Ast *> *cla
check_expr(ctx, &o, clause);
if (o.mode != Addressing_Constant) {
if (print_err) error(clause, "'where' clauses expect a constant boolean evaluation");
+ if (print_err && call_expr) error(call_expr, "at caller location");
return false;
} else if (o.value.kind != ExactValue_Bool) {
if (print_err) error(clause, "'where' clauses expect a constant boolean evaluation");
+ if (print_err && call_expr) error(call_expr, "at caller location");
return false;
} else if (!o.value.value_bool) {
if (print_err) {
@@ -6348,6 +6354,7 @@ bool evaluate_where_clauses(CheckerContext *ctx, Scope *scope, Array<Ast *> *cla
}
}
+ if (call_expr) error(call_expr, "at caller location");
}
return false;
}
@@ -6613,7 +6620,7 @@ CallArgumentData check_call_arguments(CheckerContext *c, Operand *operand, Type
ctx.curr_proc_sig = e->type;
GB_ASSERT(decl->proc_lit->kind == Ast_ProcLit);
- if (!evaluate_where_clauses(&ctx, decl->scope, &decl->proc_lit->ProcLit.where_clauses, false)) {
+ if (!evaluate_where_clauses(&ctx, operand->expr, decl->scope, &decl->proc_lit->ProcLit.where_clauses, false)) {
continue;
}
}