diff options
| author | gingerBill <bill@gingerbill.org> | 2022-02-05 16:11:48 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2022-02-05 16:11:48 +0000 |
| commit | 445ca705210999e106b6aeb265cfb2979cbd857c (patch) | |
| tree | e84522945e73ae60f11976d017ac9722600ef017 /src/check_expr.cpp | |
| parent | c6ab8f82c88f7d5470fa2fb0459d09ba8a67a287 (diff) | |
Correct implicit union cast
Diffstat (limited to 'src/check_expr.cpp')
| -rw-r--r-- | src/check_expr.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp index fb58839bc..3f31ac810 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -508,6 +508,10 @@ bool check_cast_internal(CheckerContext *c, Operand *x, Type *type); #define MAXIMUM_TYPE_DISTANCE 10 i64 check_distance_between_types(CheckerContext *c, Operand *operand, Type *type) { + if (c == nullptr) { + GB_ASSERT(operand->mode == Addressing_Value); + GB_ASSERT(is_type_typed(operand->type)); + } if (operand->mode == Addressing_Invalid || type == t_invalid) { return -1; @@ -818,6 +822,13 @@ bool check_is_assignable_to(CheckerContext *c, Operand *operand, Type *type) { return check_is_assignable_to_with_score(c, operand, type, &score); } +bool internal_check_is_assignable_to(Type *src, Type *dst) { + Operand x = {}; + x.type = src; + x.mode = Addressing_Value; + return check_is_assignable_to(nullptr, &x, dst); +} + AstPackage *get_package_of_type(Type *type) { for (;;) { if (type == nullptr) { |