diff options
| author | gingerBill <bill@gingerbill.org> | 2019-11-03 19:49:21 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2019-11-03 19:49:21 +0000 |
| commit | c1176c2bcb919118e916a0ef2292ddc0f89f5bf7 (patch) | |
| tree | a29bdc0b59be064b3f4a9965143458af07118c35 /src/check_expr.cpp | |
| parent | 57853fe1b118970e1fc7149a7f030f4152e7157d (diff) | |
Fix typeid comparison bug; Add extra messages for pointer address errors
Diffstat (limited to 'src/check_expr.cpp')
| -rw-r--r-- | src/check_expr.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 48b430248..1d59f0530 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -1645,7 +1645,17 @@ void check_unary_expr(CheckerContext *c, Operand *o, Token op, Ast *node) { if (e != nullptr && (e->flags & EntityFlag_Param) != 0) { error(op, "Cannot take the pointer address of '%s' which is a procedure parameter", str); } else { - error(op, "Cannot take the pointer address of '%s'", str); + switch (o->mode) { + case Addressing_SoaVariable: + error(op, "Cannot take the pointer address of '%s' as it is an indirect index of an SOA struct", str); + break; + case Addressing_Constant: + error(op, "Cannot take the pointer address of '%s' which is a constant", str); + break; + default: + error(op, "Cannot take the pointer address of '%s'", str); + break; + } } } o->mode = Addressing_Invalid; @@ -1731,12 +1741,14 @@ void check_comparison(CheckerContext *c, Operand *x, Operand *y, TokenKind op) { if (x->mode == Addressing_Type && is_type_typeid(y->type)) { add_type_info_type(c, x->type); + add_type_info_type(c, y->type); add_type_and_value(c->info, x->expr, Addressing_Value, y->type, exact_value_typeid(x->type)); x->mode = Addressing_Value; x->type = t_untyped_bool; return; } else if (is_type_typeid(x->type) && y->mode == Addressing_Type) { + add_type_info_type(c, x->type); add_type_info_type(c, y->type); add_type_and_value(c->info, y->expr, Addressing_Value, x->type, exact_value_typeid(y->type)); |