aboutsummaryrefslogtreecommitdiff
path: root/src/check_type.cpp
diff options
context:
space:
mode:
authorBenoit Jacquier <benoit.jacquier@gmail.com>2022-08-27 16:22:37 +0200
committerBenoit Jacquier <benoit.jacquier@gmail.com>2022-08-27 16:22:37 +0200
commit4e5337412a4e46fb26250f8adf1d019ddd8366c7 (patch)
treea49c22bd4c894a26ddf8da92c10894fb8e03383f /src/check_type.cpp
parent00f2e911a73e99b1283306272ff433984d90486c (diff)
parentc82d7d3d87c2dc77ce942b1cc450734baca3da14 (diff)
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'src/check_type.cpp')
-rw-r--r--src/check_type.cpp33
1 files changed, 24 insertions, 9 deletions
diff --git a/src/check_type.cpp b/src/check_type.cpp
index dea523599..da0a9706b 100644
--- a/src/check_type.cpp
+++ b/src/check_type.cpp
@@ -695,11 +695,6 @@ void check_union_type(CheckerContext *ctx, Type *union_type, Ast *node, Array<Op
error(ut->align, "A union with #no_nil must have at least 2 variants");
}
break;
- case UnionType_maybe:
- if (variants.count != 1) {
- error(ut->align, "A union with #maybe must have at 1 variant, got %lld", cast(long long)variants.count);
- }
- break;
}
if (ut->align != nullptr) {
@@ -2698,9 +2693,12 @@ bool check_type_internal(CheckerContext *ctx, Ast *e, Type **type, Type *named_t
case_ast_node(ue, UnaryExpr, e);
switch (ue->op.kind) {
case Token_Pointer:
- *type = alloc_type_pointer(check_type(ctx, ue->expr));
- set_base_type(named_type, *type);
- return true;
+ {
+ Type *elem = check_type(ctx, ue->expr);
+ *type = alloc_type_pointer(elem);
+ set_base_type(named_type, *type);
+ return true;
+ }
}
case_end;
@@ -2726,7 +2724,24 @@ bool check_type_internal(CheckerContext *ctx, Ast *e, Type **type, Type *named_t
elem = o.type;
}
- *type = alloc_type_pointer(elem);
+ if (pt->tag != nullptr) {
+ GB_ASSERT(pt->tag->kind == Ast_BasicDirective);
+ String name = pt->tag->BasicDirective.name.string;
+ if (name == "soa") {
+ // TODO(bill): generic #soa pointers
+ if (is_type_soa_struct(elem)) {
+ *type = alloc_type_soa_pointer(elem);
+ } else {
+ error(pt->tag, "#soa pointers require an #soa record type as the element");
+ *type = alloc_type_pointer(elem);
+ }
+ } else {
+ error(pt->tag, "Invalid tag applied to pointer, got #%.*s", LIT(name));
+ *type = alloc_type_pointer(elem);
+ }
+ } else {
+ *type = alloc_type_pointer(elem);
+ }
set_base_type(named_type, *type);
return true;
case_end;