mirror of
https://github.com/odin-lang/Odin.git
synced 2026-02-13 23:03:16 +00:00
Add struct #no_copy
This commit is contained in:
@@ -5043,6 +5043,21 @@ gb_internal isize add_dependencies_from_unpacking(CheckerContext *c, Entity **lh
|
||||
return tuple_count;
|
||||
}
|
||||
|
||||
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) {
|
||||
if (expr->kind == Ast_CallExpr) {
|
||||
// Okay
|
||||
} else {
|
||||
error(o.expr, "Invalid use a #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;
|
||||
@@ -5114,6 +5129,7 @@ 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;
|
||||
@@ -5952,6 +5968,10 @@ gb_internal CallArgumentData check_call_arguments(CheckerContext *c, Operand *op
|
||||
}
|
||||
}
|
||||
|
||||
for (Operand const &o : operands) {
|
||||
check_no_copy_assignment(o, str_lit("call expression"));
|
||||
}
|
||||
|
||||
if (operand->mode == Addressing_ProcGroup) {
|
||||
check_entity_decl(c, operand->proc_group, nullptr, nullptr);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user