mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 07:38:48 +00:00
Revert accidental removal of #const for procedure variable parameters #718
This commit is contained in:
@@ -1662,6 +1662,10 @@ Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_params, bool *is
|
|||||||
error(name, "'auto_cast' can only be applied to variable fields");
|
error(name, "'auto_cast' can only be applied to variable fields");
|
||||||
p->flags &= ~FieldFlag_auto_cast;
|
p->flags &= ~FieldFlag_auto_cast;
|
||||||
}
|
}
|
||||||
|
if (p->flags&FieldFlag_const) {
|
||||||
|
error(name, "'#const' can only be applied to variable fields");
|
||||||
|
p->flags &= ~FieldFlag_const;
|
||||||
|
}
|
||||||
|
|
||||||
param = alloc_entity_type_name(scope, name->Ident.token, type, EntityState_Resolved);
|
param = alloc_entity_type_name(scope, name->Ident.token, type, EntityState_Resolved);
|
||||||
param->TypeName.is_type_alias = true;
|
param->TypeName.is_type_alias = true;
|
||||||
@@ -1726,6 +1730,10 @@ Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_params, bool *is
|
|||||||
error(name, "'auto_cast' can only be applied to variable fields");
|
error(name, "'auto_cast' can only be applied to variable fields");
|
||||||
p->flags &= ~FieldFlag_auto_cast;
|
p->flags &= ~FieldFlag_auto_cast;
|
||||||
}
|
}
|
||||||
|
if (p->flags&FieldFlag_const) {
|
||||||
|
error(name, "'#const' can only be applied to variable fields");
|
||||||
|
p->flags &= ~FieldFlag_const;
|
||||||
|
}
|
||||||
|
|
||||||
if (!is_type_constant_type(type) && !is_type_polymorphic(type)) {
|
if (!is_type_constant_type(type) && !is_type_polymorphic(type)) {
|
||||||
gbString str = type_to_string(type);
|
gbString str = type_to_string(type);
|
||||||
@@ -1745,6 +1753,9 @@ Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_params, bool *is
|
|||||||
if (p->flags&FieldFlag_auto_cast) {
|
if (p->flags&FieldFlag_auto_cast) {
|
||||||
param->flags |= EntityFlag_AutoCast;
|
param->flags |= EntityFlag_AutoCast;
|
||||||
}
|
}
|
||||||
|
if (p->flags&FieldFlag_const) {
|
||||||
|
param->flags |= EntityFlag_ConstInput;
|
||||||
|
}
|
||||||
|
|
||||||
param->state = EntityState_Resolved; // NOTE(bill): This should have be resolved whilst determining it
|
param->state = EntityState_Resolved; // NOTE(bill): This should have be resolved whilst determining it
|
||||||
add_entity(ctx->checker, scope, name, param);
|
add_entity(ctx->checker, scope, name, param);
|
||||||
|
|||||||
@@ -3127,6 +3127,7 @@ u32 parse_field_prefixes(AstFile *f) {
|
|||||||
i32 no_alias_count = 0;
|
i32 no_alias_count = 0;
|
||||||
i32 c_vararg_count = 0;
|
i32 c_vararg_count = 0;
|
||||||
i32 auto_cast_count = 0;
|
i32 auto_cast_count = 0;
|
||||||
|
i32 const_count = 0;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
FieldPrefixKind kind = is_token_field_prefix(f);
|
FieldPrefixKind kind = is_token_field_prefix(f);
|
||||||
@@ -3144,12 +3145,14 @@ u32 parse_field_prefixes(AstFile *f) {
|
|||||||
case FieldPrefix_no_alias: no_alias_count += 1; advance_token(f); break;
|
case FieldPrefix_no_alias: no_alias_count += 1; advance_token(f); break;
|
||||||
case FieldPrefix_c_var_arg: c_vararg_count += 1; advance_token(f); break;
|
case FieldPrefix_c_var_arg: c_vararg_count += 1; advance_token(f); break;
|
||||||
case FieldPrefix_auto_cast: auto_cast_count += 1; advance_token(f); break;
|
case FieldPrefix_auto_cast: auto_cast_count += 1; advance_token(f); break;
|
||||||
|
case FieldPrefix_const: const_count += 1; advance_token(f); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (using_count > 1) syntax_error(f->curr_token, "Multiple 'using' in this field list");
|
if (using_count > 1) syntax_error(f->curr_token, "Multiple 'using' in this field list");
|
||||||
if (no_alias_count > 1) syntax_error(f->curr_token, "Multiple '#no_alias' in this field list");
|
if (no_alias_count > 1) syntax_error(f->curr_token, "Multiple '#no_alias' in this field list");
|
||||||
if (c_vararg_count > 1) syntax_error(f->curr_token, "Multiple '#c_vararg' in this field list");
|
if (c_vararg_count > 1) syntax_error(f->curr_token, "Multiple '#c_vararg' in this field list");
|
||||||
if (auto_cast_count > 1) syntax_error(f->curr_token, "Multiple 'auto_cast' in this field list");
|
if (auto_cast_count > 1) syntax_error(f->curr_token, "Multiple 'auto_cast' in this field list");
|
||||||
|
if (const_count > 1) syntax_error(f->curr_token, "Multiple '#const' in this field list");
|
||||||
|
|
||||||
|
|
||||||
u32 field_flags = 0;
|
u32 field_flags = 0;
|
||||||
@@ -3157,6 +3160,7 @@ u32 parse_field_prefixes(AstFile *f) {
|
|||||||
if (no_alias_count > 0) field_flags |= FieldFlag_no_alias;
|
if (no_alias_count > 0) field_flags |= FieldFlag_no_alias;
|
||||||
if (c_vararg_count > 0) field_flags |= FieldFlag_c_vararg;
|
if (c_vararg_count > 0) field_flags |= FieldFlag_c_vararg;
|
||||||
if (auto_cast_count > 0) field_flags |= FieldFlag_auto_cast;
|
if (auto_cast_count > 0) field_flags |= FieldFlag_auto_cast;
|
||||||
|
if (const_count > 0) field_flags |= FieldFlag_const;
|
||||||
return field_flags;
|
return field_flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -212,12 +212,13 @@ enum FieldFlag {
|
|||||||
FieldFlag_no_alias = 1<<2,
|
FieldFlag_no_alias = 1<<2,
|
||||||
FieldFlag_c_vararg = 1<<3,
|
FieldFlag_c_vararg = 1<<3,
|
||||||
FieldFlag_auto_cast = 1<<4,
|
FieldFlag_auto_cast = 1<<4,
|
||||||
|
FieldFlag_const = 1<<5,
|
||||||
|
|
||||||
FieldFlag_Tags = 1<<10,
|
FieldFlag_Tags = 1<<10,
|
||||||
|
|
||||||
FieldFlag_Results = 1<<16,
|
FieldFlag_Results = 1<<16,
|
||||||
|
|
||||||
FieldFlag_Signature = FieldFlag_ellipsis|FieldFlag_using|FieldFlag_no_alias|FieldFlag_c_vararg|FieldFlag_auto_cast,
|
FieldFlag_Signature = FieldFlag_ellipsis|FieldFlag_using|FieldFlag_no_alias|FieldFlag_c_vararg|FieldFlag_auto_cast|FieldFlag_const,
|
||||||
FieldFlag_Struct = FieldFlag_using|FieldFlag_Tags,
|
FieldFlag_Struct = FieldFlag_using|FieldFlag_Tags,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user