aboutsummaryrefslogtreecommitdiff
path: root/src/checker.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/checker.cpp')
-rw-r--r--src/checker.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/checker.cpp b/src/checker.cpp
index d4094d6ed..19577ef70 100644
--- a/src/checker.cpp
+++ b/src/checker.cpp
@@ -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));