mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Fix void[] -> char[] cast.
This commit is contained in:
@@ -109,7 +109,7 @@ fn usz! File.read(self, char[] buffer)
|
||||
*/
|
||||
fn usz! File.read_any(self, any ref)
|
||||
{
|
||||
return self.read(((char*)ref.ptr)[:ref.type.sizeof]);
|
||||
return self.read(ref.ptr[:ref.type.sizeof]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,7 +128,7 @@ fn usz! File.write(self, char[] buffer)
|
||||
*/
|
||||
fn usz! File.write_any(self, any ref)
|
||||
{
|
||||
return self.write(((char*)ref.ptr)[:ref.type.sizeof]);
|
||||
return self.write(ref.ptr[:ref.type.sizeof]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -232,6 +232,7 @@ fn void! Formatter.out_str(&self, any arg) @private
|
||||
{
|
||||
return self.out_substr(*(String*)arg);
|
||||
}
|
||||
if (inner == void.typeid) inner = char.typeid;
|
||||
usz size = inner.sizeof;
|
||||
// Pretend this is a String
|
||||
String* temp = (void*)arg.ptr;
|
||||
|
||||
@@ -79,7 +79,7 @@ fn usz! Stream.available(self) @inline
|
||||
|
||||
fn usz! Stream.read_any(self, any ref)
|
||||
{
|
||||
return self.read(((char*)ref.ptr)[:ref.type.sizeof]);
|
||||
return self.read(ref.ptr[:ref.type.sizeof]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,7 +89,7 @@ fn usz! Stream.read_any(self, any ref)
|
||||
*/
|
||||
fn usz! Stream.write_any(self, any ref)
|
||||
{
|
||||
return self.write(((char*)ref.ptr)[:ref.type.sizeof]);
|
||||
return self.write(ref.ptr[:ref.type.sizeof]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -474,7 +474,9 @@ static bool array_to_vector(Expr *expr, Type *to_type)
|
||||
*/
|
||||
INLINE bool subarray_to_subarray(Expr *expr, Type *to_type)
|
||||
{
|
||||
if (expr_is_const(expr) || type_flatten(type_flatten(to_type)->array.base) == type_flatten(type_flatten(expr->type)->array.base))
|
||||
Type *to_type_base = type_flatten(type_flatten(to_type)->array.base);
|
||||
Type *from_type_base = type_flatten(type_flatten(expr->type)->array.base);
|
||||
if (expr_is_const(expr) || to_type_base == from_type_base || (to_type_base == type_void || from_type_base == type_void))
|
||||
{
|
||||
// Here we assume int[] -> float[] can't happen.
|
||||
expr->type = to_type;
|
||||
|
||||
@@ -1662,6 +1662,10 @@ TypeCmpResult type_array_element_is_equivalent(SemaContext *context, Type *eleme
|
||||
element2 = element2->canonical;
|
||||
}
|
||||
if (element1 == element2) return TYPE_SAME;
|
||||
if ((element1 == type_void && element2 == type_char) || (element1 == type_char && element2 == type_void))
|
||||
{
|
||||
return TYPE_SAME;
|
||||
}
|
||||
switch (element1->type_kind)
|
||||
{
|
||||
case TYPE_POINTER:
|
||||
|
||||
Reference in New Issue
Block a user