mirror of
https://github.com/odin-lang/Odin.git
synced 2026-04-20 21:35:19 +00:00
Allow @(deprecated=<string>) on types
This commit is contained in:
@@ -518,6 +518,8 @@ gb_internal void check_type_decl(CheckerContext *ctx, Entity *e, Ast *init_expr,
|
||||
AttributeContext ac = {};
|
||||
check_decl_attributes(ctx, decl->attributes, type_decl_attribute, &ac);
|
||||
|
||||
e->deprecated_message = ac.deprecated_message;
|
||||
|
||||
if (e->kind == Entity_TypeName && ac.objc_class != "") {
|
||||
|
||||
e->TypeName.objc_class_name = ac.objc_class;
|
||||
|
||||
@@ -4282,6 +4282,20 @@ gb_internal DECL_ATTRIBUTE_PROC(type_decl_attribute) {
|
||||
error(elem, "Expected a string or no value for '%.*s'", LIT(name));
|
||||
}
|
||||
return true;
|
||||
} else if (name == "deprecated") {
|
||||
ExactValue ev = check_decl_attribute_value(c, value);
|
||||
|
||||
if (ev.kind == ExactValue_String) {
|
||||
String msg = ev.value_string;
|
||||
if (msg.len == 0) {
|
||||
error(elem, "Deprecation message cannot be an empty string");
|
||||
} else {
|
||||
ac->deprecated_message = msg;
|
||||
}
|
||||
} else {
|
||||
error(elem, "Expected a string value for '%.*s'", LIT(name));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user