mirror of
https://github.com/odin-lang/Odin.git
synced 2026-02-16 08:04:07 +00:00
Add @(warning=<string>)
This commit is contained in:
@@ -1303,6 +1303,10 @@ void add_entity_use(CheckerContext *c, Ast *identifier, Entity *entity) {
|
||||
if (dmsg.len > 0) {
|
||||
warning(identifier, "%.*s is deprecated: %.*s", LIT(entity->token.string), LIT(dmsg));
|
||||
}
|
||||
String wmsg = entity->warning_message;
|
||||
if (wmsg.len > 0) {
|
||||
warning(identifier, "%.*s: %.*s", LIT(entity->token.string), LIT(wmsg));
|
||||
}
|
||||
}
|
||||
entity->flags |= EntityFlag_Used;
|
||||
add_declaration_dependency(c, entity);
|
||||
@@ -2698,6 +2702,20 @@ DECL_ATTRIBUTE_PROC(proc_decl_attribute) {
|
||||
error(elem, "Expected a string value for '%.*s'", LIT(name));
|
||||
}
|
||||
return true;
|
||||
} else if (name == "warning") {
|
||||
ExactValue ev = check_decl_attribute_value(c, value);
|
||||
|
||||
if (ev.kind == ExactValue_String) {
|
||||
String msg = ev.value_string;
|
||||
if (msg.len == 0) {
|
||||
error(elem, "Warning message cannot be an empty string");
|
||||
} else {
|
||||
ac->warning_message = msg;
|
||||
}
|
||||
} else {
|
||||
error(elem, "Expected a string value for '%.*s'", LIT(name));
|
||||
}
|
||||
return true;
|
||||
} else if (name == "require_results") {
|
||||
if (value != nullptr) {
|
||||
error(elem, "Expected no value for '%.*s'", LIT(name));
|
||||
|
||||
Reference in New Issue
Block a user