aboutsummaryrefslogtreecommitdiff
path: root/src/check_type.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/check_type.cpp')
-rw-r--r--src/check_type.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/check_type.cpp b/src/check_type.cpp
index 741385e29..dea523599 100644
--- a/src/check_type.cpp
+++ b/src/check_type.cpp
@@ -1616,6 +1616,10 @@ Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_params, bool *is
error(name, "'#any_int' can only be applied to variable fields");
p->flags &= ~FieldFlag_any_int;
}
+ if (p->flags&FieldFlag_by_ptr) {
+ error(name, "'#by_ptr' can only be applied to variable fields");
+ p->flags &= ~FieldFlag_by_ptr;
+ }
param = alloc_entity_type_name(scope, name->Ident.token, type, EntityState_Resolved);
param->TypeName.is_type_alias = true;
@@ -1692,10 +1696,17 @@ Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_params, bool *is
if (p->flags&FieldFlag_no_alias) {
if (!is_type_pointer(type)) {
- error(name, "'#no_alias' can only be applied to fields of pointer type");
+ error(name, "'#no_alias' can only be applied pointer typed parameters");
p->flags &= ~FieldFlag_no_alias; // Remove the flag
}
}
+ if (p->flags&FieldFlag_by_ptr) {
+ if (is_type_internally_pointer_like(type)) {
+ error(name, "'#by_ptr' can only be applied to non-pointer-like parameters");
+ p->flags &= ~FieldFlag_by_ptr; // Remove the flag
+ }
+ }
+
if (is_poly_name) {
if (p->flags&FieldFlag_no_alias) {
error(name, "'#no_alias' can only be applied to non constant values");
@@ -1713,6 +1724,10 @@ Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_params, bool *is
error(name, "'#const' can only be applied to variable fields");
p->flags &= ~FieldFlag_const;
}
+ if (p->flags&FieldFlag_by_ptr) {
+ error(name, "'#by_ptr' can only be applied to variable fields");
+ p->flags &= ~FieldFlag_by_ptr;
+ }
if (!is_type_constant_type(type) && !is_type_polymorphic(type)) {
gbString str = type_to_string(type);
@@ -1745,6 +1760,9 @@ Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_params, bool *is
if (p->flags&FieldFlag_const) {
param->flags |= EntityFlag_ConstInput;
}
+ if (p->flags&FieldFlag_by_ptr) {
+ param->flags |= EntityFlag_ByPtr;
+ }
param->state = EntityState_Resolved; // NOTE(bill): This should have be resolved whilst determining it
add_entity(ctx, scope, name, param);