From 7abaf77292ea9d45ca135e9c166dbba5c9fe3af2 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sat, 15 Apr 2023 15:47:18 +0100 Subject: [PATCH] Add `struct #no_copy` --- core/odin/ast/ast.odin | 1 + core/odin/parser/parser.odin | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/core/odin/ast/ast.odin b/core/odin/ast/ast.odin index 99b2cde98..58d977171 100644 --- a/core/odin/ast/ast.odin +++ b/core/odin/ast/ast.odin @@ -740,6 +740,7 @@ Struct_Type :: struct { where_clauses: []^Expr, is_packed: bool, is_raw_union: bool, + is_no_copy: bool, fields: ^Field_List, name_count: int, } diff --git a/core/odin/parser/parser.odin b/core/odin/parser/parser.odin index 29af7e71e..15a33d86b 100644 --- a/core/odin/parser/parser.odin +++ b/core/odin/parser/parser.odin @@ -2527,6 +2527,7 @@ parse_operand :: proc(p: ^Parser, lhs: bool) -> ^ast.Expr { align: ^ast.Expr is_packed: bool is_raw_union: bool + is_no_copy: bool fields: ^ast.Field_List name_count: int @@ -2560,6 +2561,11 @@ parse_operand :: proc(p: ^Parser, lhs: bool) -> ^ast.Expr { error(p, tag.pos, "duplicate struct tag '#%s'", tag.text) } is_raw_union = true + case "no_copy": + if is_no_copy { + error(p, tag.pos, "duplicate struct tag '#%s'", tag.text) + } + is_no_copy = true case: error(p, tag.pos, "invalid struct tag '#%s", tag.text) } @@ -2594,6 +2600,7 @@ parse_operand :: proc(p: ^Parser, lhs: bool) -> ^ast.Expr { st.align = align st.is_packed = is_packed st.is_raw_union = is_raw_union + st.is_no_copy = is_no_copy st.fields = fields st.name_count = name_count st.where_token = where_token