mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Remove predefined c type aliases.
This commit is contained in:
@@ -1435,8 +1435,6 @@ extern Type *type_char, *type_ushort, *type_uint, *type_ulong, *type_usize;
|
||||
extern Type *type_iptr, *type_uptr, *type_iptrdiff, *type_uptrdiff;
|
||||
extern Type *type_u128, *type_i128;
|
||||
extern Type *type_compint, *type_compfloat;
|
||||
extern Type *type_c_short, *type_c_int, *type_c_long, *type_c_longlong;
|
||||
extern Type *type_c_ushort, *type_c_uint, *type_c_ulong, *type_c_ulonglong;
|
||||
extern Type *type_typeid, *type_error, *type_typeinfo, *type_varheader;
|
||||
extern Type *type_virtual, *type_virtual_generic;
|
||||
|
||||
@@ -1810,6 +1808,8 @@ Type *type_get_subarray(Type *arr_type);
|
||||
Type *type_get_inferred_array(Type *arr_type);
|
||||
|
||||
Type *type_get_vector(Type *vector_type, unsigned len);
|
||||
Type *type_cint(void);
|
||||
Type *type_cuint(void);
|
||||
Type *type_int_signed_by_bitsize(unsigned bytesize);
|
||||
Type *type_int_unsigned_by_bitsize(unsigned bytesize);
|
||||
bool type_is_abi_aggregate(Type *type);
|
||||
@@ -1879,7 +1879,6 @@ static inline bool type_is_integer(Type *type)
|
||||
return type->type_kind >= TYPE_I8 && type->type_kind < TYPE_IXX;
|
||||
}
|
||||
|
||||
|
||||
static inline bool type_is_any_integer(Type *type)
|
||||
{
|
||||
assert(type == type->canonical);
|
||||
@@ -2118,7 +2117,7 @@ static inline DeclKind decl_from_token(TokenType type)
|
||||
static inline bool type_is_promotable_integer(Type *type)
|
||||
{
|
||||
// If we support other architectures, update this.
|
||||
return type_is_integer_kind(type) && type->builtin.bytesize < type_c_int->canonical->builtin.bytesize;
|
||||
return type_is_integer_kind(type) && type->builtin.bitsize < platform_target.width_c_int;
|
||||
}
|
||||
|
||||
static inline bool type_is_promotable_float(Type *type)
|
||||
|
||||
@@ -890,16 +890,18 @@ static inline bool sema_expr_analyse_func_invocation(Context *context, FunctionS
|
||||
Type *arg_type = arg->type->canonical;
|
||||
if (type_is_ct(arg_type))
|
||||
{
|
||||
// TODO Fix the int conversion.
|
||||
// 12c. Pick double / CInt
|
||||
Type *target_type = type_is_any_integer(arg_type) ? type_c_int->canonical : type_double;
|
||||
Type *target_type = type_is_any_integer(arg_type) ? type_cint() : type_double;
|
||||
if (!cast_implicit(arg, target_type)) return false;
|
||||
arg_type = target_type;
|
||||
}
|
||||
// 12d. Promote any integer or bool to at least CInt
|
||||
if (type_is_promotable_integer(arg_type) || arg_type == type_bool)
|
||||
{
|
||||
cast(arg, type_c_int->canonical);
|
||||
arg_type = type_c_int->canonical;
|
||||
Type *cint = type_cint();
|
||||
cast(arg, cint);
|
||||
arg_type = cint;
|
||||
}
|
||||
// 12e. Promote any float to at least Double
|
||||
if (type_is_promotable_float(arg->type))
|
||||
@@ -3285,8 +3287,10 @@ static Type *numeric_arithmetic_promotion(Type *type)
|
||||
switch (type->type_kind)
|
||||
{
|
||||
case ALL_SIGNED_INTS:
|
||||
if (type->builtin.bitsize < platform_target.width_c_int) return type_cint();
|
||||
return type;
|
||||
case ALL_UNSIGNED_INTS:
|
||||
if (type->builtin.bitsize < platform_target.width_c_int) return type_c_int->canonical;
|
||||
if (type->builtin.bitsize < platform_target.width_c_int) return type_cuint();
|
||||
return type;
|
||||
case TYPE_F16:
|
||||
// Promote F16 to a real type.
|
||||
|
||||
@@ -11,8 +11,6 @@ static struct
|
||||
Type u8, u16, u32, u64, u128;
|
||||
Type f16, f32, f64, f128, fxx;
|
||||
Type usz, isz, uptr, iptr, uptrdiff, iptrdiff;
|
||||
Type t_cus, t_cui, t_cul, t_cull;
|
||||
Type t_cs, t_ci, t_cl, t_cll;
|
||||
Type voidstar, typeid, error, typeinfo;
|
||||
Type str, varheader, virtual, virtual_generic;
|
||||
|
||||
@@ -48,14 +46,6 @@ Type *type_usize = &t.usz;
|
||||
Type *type_compint = &t.ixx;
|
||||
Type *type_compfloat = &t.fxx;
|
||||
Type *type_compstr = &t.str;
|
||||
Type *type_c_short = &t.t_cs;
|
||||
Type *type_c_int = &t.t_ci;
|
||||
Type *type_c_long = &t.t_cl;
|
||||
Type *type_c_longlong = &t.t_cll;
|
||||
Type *type_c_ushort = &t.t_cus;
|
||||
Type *type_c_uint = &t.t_cui;
|
||||
Type *type_c_ulong = &t.t_cul;
|
||||
Type *type_c_ulonglong = &t.t_cull;
|
||||
Type *type_error = &t.error;
|
||||
Type *type_varheader = &t.varheader;
|
||||
|
||||
@@ -69,6 +59,16 @@ unsigned alignment_error_code;
|
||||
#define SUB_ARRAY_OFFSET 2
|
||||
#define ARRAY_OFFSET 3
|
||||
|
||||
Type *type_cint(void)
|
||||
{
|
||||
return type_int_signed_by_bitsize(platform_target.width_c_int);
|
||||
}
|
||||
|
||||
Type *type_cuint(void)
|
||||
{
|
||||
return type_int_unsigned_by_bitsize(platform_target.width_c_int);
|
||||
}
|
||||
|
||||
Type *type_int_signed_by_bitsize(unsigned bytesize)
|
||||
{
|
||||
switch (bytesize)
|
||||
@@ -1164,16 +1164,6 @@ type_create(#name_, &(shortname_), type_, bits_, target->align_ ## aligned_, tar
|
||||
type_create_alias("uptrdiff", &t.uptrdiff, type_int_unsigned_by_bitsize(target->width_pointer));
|
||||
type_create_alias("iptrdiff", &t.iptrdiff, type_int_signed_by_bitsize(target->width_pointer));
|
||||
|
||||
type_create_alias("c_ushort", &t.t_cus, type_int_unsigned_by_bitsize(target->width_c_short));
|
||||
type_create_alias("c_uint", &t.t_cui, type_int_unsigned_by_bitsize(target->width_c_int));
|
||||
type_create_alias("c_ulong", &t.t_cul, type_int_unsigned_by_bitsize(target->width_c_long));
|
||||
type_create_alias("c_ulonglong", &t.t_cull, type_int_unsigned_by_bitsize(target->width_c_long_long));
|
||||
|
||||
type_create_alias("c_short", &t.t_cs, type_int_signed_by_bitsize(target->width_c_short));
|
||||
type_create_alias("c_int", &t.t_ci, type_int_signed_by_bitsize(target->width_c_int));
|
||||
type_create_alias("c_long", &t.t_cl, type_int_signed_by_bitsize(target->width_c_long));
|
||||
type_create_alias("c_longlong", &t.t_cll, type_int_signed_by_bitsize(target->width_c_long_long));
|
||||
|
||||
alignment_subarray = MAX(type_abi_alignment(&t.voidstar), type_abi_alignment(t.usz.canonical));
|
||||
size_subarray = alignment_subarray * 2;
|
||||
type_create("error", &t.error, TYPE_ERR_UNION, target->width_pointer * 2, target->align_pointer, target->align_pref_pointer);
|
||||
|
||||
Reference in New Issue
Block a user