mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 23:28:48 +00:00
Fix typeid comparison bug; Add extra messages for pointer address errors
This commit is contained in:
+11
-1
@@ -1350,7 +1350,17 @@ soa_struct_layout :: proc() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
main :: proc() {
|
main :: proc() {
|
||||||
when true {
|
id: typeid;
|
||||||
|
id = typeid_of(int);
|
||||||
|
|
||||||
|
if id == bool {
|
||||||
|
fmt.println("HERE1");
|
||||||
|
}
|
||||||
|
fmt.println("HERE2");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
when false {
|
||||||
extra_general_stuff();
|
extra_general_stuff();
|
||||||
union_type();
|
union_type();
|
||||||
parametric_polymorphism();
|
parametric_polymorphism();
|
||||||
|
|||||||
+13
-1
@@ -1645,7 +1645,17 @@ void check_unary_expr(CheckerContext *c, Operand *o, Token op, Ast *node) {
|
|||||||
if (e != nullptr && (e->flags & EntityFlag_Param) != 0) {
|
if (e != nullptr && (e->flags & EntityFlag_Param) != 0) {
|
||||||
error(op, "Cannot take the pointer address of '%s' which is a procedure parameter", str);
|
error(op, "Cannot take the pointer address of '%s' which is a procedure parameter", str);
|
||||||
} else {
|
} 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;
|
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)) {
|
if (x->mode == Addressing_Type && is_type_typeid(y->type)) {
|
||||||
add_type_info_type(c, x->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));
|
add_type_and_value(c->info, x->expr, Addressing_Value, y->type, exact_value_typeid(x->type));
|
||||||
|
|
||||||
x->mode = Addressing_Value;
|
x->mode = Addressing_Value;
|
||||||
x->type = t_untyped_bool;
|
x->type = t_untyped_bool;
|
||||||
return;
|
return;
|
||||||
} else if (is_type_typeid(x->type) && y->mode == Addressing_Type) {
|
} 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_info_type(c, y->type);
|
||||||
add_type_and_value(c->info, y->expr, Addressing_Value, x->type, exact_value_typeid(y->type));
|
add_type_and_value(c->info, y->expr, Addressing_Value, x->type, exact_value_typeid(y->type));
|
||||||
|
|
||||||
|
|||||||
@@ -1036,6 +1036,8 @@ void add_type_and_value(CheckerInfo *i, Ast *expr, AddressingMode mode, Type *ty
|
|||||||
expr->tav.type = type;
|
expr->tav.type = type;
|
||||||
if (mode == Addressing_Constant || mode == Addressing_Invalid) {
|
if (mode == Addressing_Constant || mode == Addressing_Invalid) {
|
||||||
expr->tav.value = value;
|
expr->tav.value = value;
|
||||||
|
} else if (mode == Addressing_Value && is_type_typeid(type)) {
|
||||||
|
expr->tav.value = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user