diff options
| author | gingerBill <bill@gingerbill.org> | 2023-04-15 15:36:21 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2023-04-15 15:37:32 +0100 |
| commit | 5da76ae34bac2f54b1bda5528cf49c0551e88bba (patch) | |
| tree | 78a6189f351ceb8dd070c2e453c4b0462d532235 /src/check_decl.cpp | |
| parent | b7b5043aea792839226baf9e6d0ca54b73dac9a5 (diff) | |
Add `struct #no_copy`
Diffstat (limited to 'src/check_decl.cpp')
| -rw-r--r-- | src/check_decl.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/check_decl.cpp b/src/check_decl.cpp index 5c25dd6a3..5a8080f96 100644 --- a/src/check_decl.cpp +++ b/src/check_decl.cpp @@ -131,6 +131,14 @@ 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)) { + begin_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 from a return value a call expression"); + } + end_error_block(); + } } if (rhs_count > 0 && lhs_count != rhs_count) { error(lhs[0]->token, "Assignment count mismatch '%td' = '%td'", lhs_count, rhs_count); |