mirror of
https://github.com/odin-lang/Odin.git
synced 2025-12-29 01:14:40 +00:00
Remove the semantics of #no_copy, keep the grammar
This commit is contained in:
@@ -115,7 +115,7 @@ Type_Info_Struct_Flags :: distinct bit_set[Type_Info_Struct_Flag; u8]
|
||||
Type_Info_Struct_Flag :: enum u8 {
|
||||
packed = 0,
|
||||
raw_union = 1,
|
||||
no_copy = 2,
|
||||
_ = 2,
|
||||
align = 3,
|
||||
}
|
||||
|
||||
|
||||
@@ -145,13 +145,6 @@ gb_internal void check_init_variables(CheckerContext *ctx, Entity **lhs, isize l
|
||||
if (d != nullptr) {
|
||||
d->init_expr = o->expr;
|
||||
}
|
||||
|
||||
if (o->type && is_type_no_copy(o->type)) {
|
||||
ERROR_BLOCK();
|
||||
if (check_no_copy_assignment(*o, str_lit("initialization"))) {
|
||||
error_line("\tInitialization of a #no_copy type must be either implicitly zero, a constant literal, or a return value from a call expression");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (rhs_count > 0 && lhs_count != rhs_count) {
|
||||
error(lhs[0]->token, "Assignment count mismatch '%td' = '%td'", lhs_count, rhs_count);
|
||||
|
||||
@@ -5763,22 +5763,6 @@ gb_internal bool check_identifier_exists(Scope *s, Ast *node, bool nested = fals
|
||||
return false;
|
||||
}
|
||||
|
||||
gb_internal bool check_no_copy_assignment(Operand const &o, String const &context) {
|
||||
if (o.type && is_type_no_copy(o.type)) {
|
||||
Ast *expr = unparen_expr(o.expr);
|
||||
if (expr && o.mode != Addressing_Constant && o.mode != Addressing_Type) {
|
||||
if (expr->kind == Ast_CallExpr) {
|
||||
// Okay
|
||||
} else {
|
||||
error(o.expr, "Invalid use of #no_copy value in %.*s", LIT(context));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
gb_internal bool check_assignment_arguments(CheckerContext *ctx, Array<Operand> const &lhs, Array<Operand> *operands, Slice<Ast *> const &rhs) {
|
||||
bool optional_ok = false;
|
||||
isize tuple_index = 0;
|
||||
@@ -5849,7 +5833,6 @@ gb_internal bool check_assignment_arguments(CheckerContext *ctx, Array<Operand>
|
||||
for (Entity *e : tuple->variables) {
|
||||
o.type = e->type;
|
||||
array_add(operands, o);
|
||||
check_no_copy_assignment(o, str_lit("assignment"));
|
||||
}
|
||||
|
||||
tuple_index += tuple->variables.count;
|
||||
@@ -6236,12 +6219,6 @@ gb_internal CallArgumentError check_call_arguments_internal(CheckerContext *c, A
|
||||
|
||||
}
|
||||
|
||||
for (Operand const &o : ordered_operands) {
|
||||
if (o.mode != Addressing_Invalid) {
|
||||
check_no_copy_assignment(o, str_lit("procedure call expression"));
|
||||
}
|
||||
}
|
||||
|
||||
for (isize i = 0; i < pt->param_count; i++) {
|
||||
if (!visited[i]) {
|
||||
Entity *e = pt->params->Tuple.variables[i];
|
||||
|
||||
@@ -430,8 +430,6 @@ gb_internal Type *check_assignment_variable(CheckerContext *ctx, Operand *lhs, O
|
||||
|
||||
Ast *node = unparen_expr(lhs->expr);
|
||||
|
||||
check_no_copy_assignment(*rhs, context_name);
|
||||
|
||||
// NOTE(bill): Ignore assignments to '_'
|
||||
if (is_blank_ident(node)) {
|
||||
check_assignment(ctx, rhs, nullptr, str_lit("assignment to '_' identifier"));
|
||||
|
||||
@@ -646,7 +646,6 @@ gb_internal void check_struct_type(CheckerContext *ctx, Type *struct_type, Ast *
|
||||
struct_type->Struct.node = node;
|
||||
struct_type->Struct.scope = ctx->scope;
|
||||
struct_type->Struct.is_packed = st->is_packed;
|
||||
struct_type->Struct.is_no_copy = st->is_no_copy;
|
||||
struct_type->Struct.polymorphic_params = check_record_polymorphic_params(
|
||||
ctx, st->polymorphic_params,
|
||||
&struct_type->Struct.is_polymorphic,
|
||||
|
||||
@@ -797,7 +797,7 @@ gb_internal void lb_setup_type_info_data_giant_array(lbModule *m, i64 global_typ
|
||||
u8 flags = 0;
|
||||
if (t->Struct.is_packed) flags |= 1<<0;
|
||||
if (t->Struct.is_raw_union) flags |= 1<<1;
|
||||
if (t->Struct.is_no_copy) flags |= 1<<2;
|
||||
//
|
||||
if (t->Struct.custom_align) flags |= 1<<3;
|
||||
|
||||
vals[6] = lb_const_int(m, t_u8, flags).value;
|
||||
|
||||
@@ -687,7 +687,6 @@ gb_internal void write_type_to_canonical_string(TypeWriter *w, Type *type) {
|
||||
|
||||
if (type->Struct.is_packed) type_writer_appendc(w, "#packed");
|
||||
if (type->Struct.is_raw_union) type_writer_appendc(w, "#raw_union");
|
||||
if (type->Struct.is_no_copy) type_writer_appendc(w, "#no_copy");
|
||||
if (type->Struct.custom_min_field_align != 0) type_writer_append_fmt(w, "#min_field_align(%lld)", cast(long long)type->Struct.custom_min_field_align);
|
||||
if (type->Struct.custom_max_field_align != 0) type_writer_append_fmt(w, "#max_field_align(%lld)", cast(long long)type->Struct.custom_max_field_align);
|
||||
if (type->Struct.custom_align != 0) type_writer_append_fmt(w, "#align(%lld)", cast(long long)type->Struct.custom_align);
|
||||
|
||||
@@ -155,7 +155,6 @@ struct TypeStruct {
|
||||
bool are_offsets_being_processed : 1;
|
||||
bool is_packed : 1;
|
||||
bool is_raw_union : 1;
|
||||
bool is_no_copy : 1;
|
||||
bool is_poly_specialized : 1;
|
||||
};
|
||||
|
||||
@@ -1780,10 +1779,6 @@ gb_internal bool is_type_raw_union(Type *t) {
|
||||
t = base_type(t);
|
||||
return (t->kind == Type_Struct && t->Struct.is_raw_union);
|
||||
}
|
||||
gb_internal bool is_type_no_copy(Type *t) {
|
||||
t = base_type(t);
|
||||
return (t->kind == Type_Struct && t->Struct.is_no_copy);
|
||||
}
|
||||
gb_internal bool is_type_enum(Type *t) {
|
||||
t = base_type(t);
|
||||
return (t->kind == Type_Enum);
|
||||
@@ -2859,7 +2854,6 @@ gb_internal bool are_types_identical_internal(Type *x, Type *y, bool check_tuple
|
||||
|
||||
case Type_Struct:
|
||||
if (x->Struct.is_raw_union == y->Struct.is_raw_union &&
|
||||
x->Struct.is_no_copy == y->Struct.is_no_copy &&
|
||||
x->Struct.fields.count == y->Struct.fields.count &&
|
||||
x->Struct.is_packed == y->Struct.is_packed &&
|
||||
x->Struct.soa_kind == y->Struct.soa_kind &&
|
||||
@@ -4832,7 +4826,6 @@ gb_internal gbString write_type_to_string(gbString str, Type *type, bool shortha
|
||||
|
||||
if (type->Struct.is_packed) str = gb_string_appendc(str, " #packed");
|
||||
if (type->Struct.is_raw_union) str = gb_string_appendc(str, " #raw_union");
|
||||
if (type->Struct.is_no_copy) str = gb_string_appendc(str, " #no_copy");
|
||||
if (type->Struct.custom_align != 0) str = gb_string_append_fmt(str, " #align %d", cast(int)type->Struct.custom_align);
|
||||
|
||||
str = gb_string_appendc(str, " {");
|
||||
|
||||
Reference in New Issue
Block a user