mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Fix bug when initializing nested struct / unions. Fix of mult of 2x2 matrix. Cleanup of cast.
This commit is contained in:
@@ -74,7 +74,7 @@ fn Matrix2x2 Matrix2x2.mul(Matrix2x2* a, Matrix2x2 b)
|
||||
{
|
||||
return Matrix2x2 {
|
||||
a.m00 * b.m00 + a.m01 * b.m10, a.m00 * b.m01 + a.m01 * b.m11,
|
||||
a.m10 * b.m01 + a.m11 * b.m11, a.m10 * b.m01 + a.m11 * b.m11,
|
||||
a.m10 * b.m00 + a.m11 * b.m10, a.m10 * b.m01 + a.m11 * b.m11,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1720,15 +1720,6 @@ static inline void llvm_emit_initialize_reference_list(GenContext *c, BEValue *r
|
||||
llvm_value_addr(c, ref);
|
||||
LLVMValueRef value = ref->value;
|
||||
|
||||
|
||||
// If this is a union, we assume it's initializing the first element.
|
||||
if (real_type->type_kind == TYPE_UNION)
|
||||
{
|
||||
assert(vec_size(elements) == 1);
|
||||
real_type = type_lowering(real_type->decl->strukt.members[0]->type);
|
||||
ref->type = real_type;
|
||||
}
|
||||
|
||||
LLVMTypeRef llvm_type = llvm_get_type(c, real_type);
|
||||
bool is_struct = type_is_union_or_strukt(real_type);
|
||||
bool is_array = real_type->type_kind == TYPE_ARRAY;
|
||||
|
||||
@@ -25,6 +25,10 @@ static bool pointer_to_pointer(Expr* expr, Type *type);
|
||||
static bool bool_to_int(Expr *expr, Type *canonical, Type *type);
|
||||
static bool bool_to_float(Expr *expr, Type *canonical, Type *type);
|
||||
static bool integer_to_bool(Expr *expr, Type *type);
|
||||
static bool float_to_bool(Expr *expr, Type *type);
|
||||
static bool float_to_float(Expr* expr, Type *canonical, Type *type);
|
||||
static bool float_to_integer(Expr *expr, Type *canonical, Type *type);
|
||||
|
||||
static bool voidfail_to_error(Expr *expr, Type *type);
|
||||
static void const_int_to_fp_cast(Expr *expr, Type *canonical, Type *type);
|
||||
INLINE bool insert_runtime_cast_unless_const(Expr *expr, CastKind kind, Type *type);
|
||||
@@ -262,7 +266,7 @@ static bool integer_to_bool(Expr *expr, Type *type)
|
||||
* Cast any float to bool using CAST_FPBOOL
|
||||
* or rewrite 0.0 => false, any other value => true
|
||||
*/
|
||||
bool float_to_bool(Expr *expr, Type *type)
|
||||
static bool float_to_bool(Expr *expr, Type *type)
|
||||
{
|
||||
if (insert_runtime_cast_unless_const(expr, CAST_FPBOOL, type)) return true;
|
||||
|
||||
@@ -288,9 +292,10 @@ static bool float_to_float(Expr* expr, Type *canonical, Type *type)
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert from any floating point to int
|
||||
* Convert from any floating point to int using CAST_FPSI / CAST_FPUI
|
||||
* Const conversion will disable narrowable and hex.
|
||||
*/
|
||||
bool float_to_integer(Expr *expr, Type *canonical, Type *type)
|
||||
static bool float_to_integer(Expr *expr, Type *canonical, Type *type)
|
||||
{
|
||||
bool is_signed = type_is_signed(canonical);
|
||||
if (insert_runtime_cast_unless_const(expr, is_signed ? CAST_FPSI : CAST_FPUI, type)) return true;
|
||||
|
||||
@@ -1 +1 @@
|
||||
#define COMPILER_VERSION "0.4.87"
|
||||
#define COMPILER_VERSION "0.4.88"
|
||||
Reference in New Issue
Block a user