Allow @(deprecated=<string>) on types

This commit is contained in:
gingerBill
2026-03-15 18:58:48 +00:00
parent 5f5c19fa2c
commit 55b3ea7c2d
2 changed files with 16 additions and 0 deletions

View File

@@ -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;

View File

@@ -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;
}