aboutsummaryrefslogtreecommitdiff
path: root/src/parser.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2022-08-08 15:07:00 +0100
committergingerBill <bill@gingerbill.org>2022-08-08 15:07:00 +0100
commit5e3cf45df3e781b0e5e01a55490a32bed0d9c7e3 (patch)
treea77078831df35c7b232a4c55714c00a22a48782c /src/parser.cpp
parent4633591918030497728675a026a45dda6201ea83 (diff)
Add `#soa` pointer type to aid with refactoring to `#soa` data types
a: #soa[16]Foo p := &a[6] #assert(type_of(p) == #soa^#soa[16]Foo) p^.x = 123 p.x = 123
Diffstat (limited to 'src/parser.cpp')
-rw-r--r--src/parser.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/parser.cpp b/src/parser.cpp
index ac3acef8a..9a5531289 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -356,6 +356,7 @@ Ast *clone_ast(Ast *node) {
break;
case Ast_PointerType:
n->PointerType.type = clone_ast(n->PointerType.type);
+ n->PointerType.tag = clone_ast(n->PointerType.tag);
break;
case Ast_MultiPointerType:
n->MultiPointerType.type = clone_ast(n->MultiPointerType.type);
@@ -2167,10 +2168,11 @@ Ast *parse_operand(AstFile *f, bool lhs) {
Ast *original_type = parse_type(f);
Ast *type = unparen_expr(original_type);
switch (type->kind) {
- case Ast_ArrayType: type->ArrayType.tag = tag; break;
+ case Ast_ArrayType: type->ArrayType.tag = tag; break;
case Ast_DynamicArrayType: type->DynamicArrayType.tag = tag; break;
+ case Ast_PointerType: type->PointerType.tag = tag; break;
default:
- syntax_error(type, "Expected an array type after #%.*s, got %.*s", LIT(name.string), LIT(ast_strings[type->kind]));
+ syntax_error(type, "Expected an array or pointer type after #%.*s, got %.*s", LIT(name.string), LIT(ast_strings[type->kind]));
break;
}
return original_type;