aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2019-08-31 14:48:56 +0100
committergingerBill <bill@gingerbill.org>2019-08-31 14:48:56 +0100
commitb311540b1672129e87a7249650a19cf11d2fccef (patch)
treee8b352fd7b21dbdee040a213e4e6fbf83ed227e3 /src
parent07ced1cf0eed9c30813d49dad0c33f29f0c161ef (diff)
Make `require_results` an attribute rather than a suffix tag for procedures
Diffstat (limited to 'src')
-rw-r--r--src/check_decl.cpp7
-rw-r--r--src/checker.cpp6
-rw-r--r--src/checker.hpp1
-rw-r--r--src/parser.cpp6
4 files changed, 15 insertions, 5 deletions
diff --git a/src/check_decl.cpp b/src/check_decl.cpp
index b5b9dc61d..7e019d82b 100644
--- a/src/check_decl.cpp
+++ b/src/check_decl.cpp
@@ -654,7 +654,6 @@ void check_proc_decl(CheckerContext *ctx, Entity *e, DeclInfo *d) {
bool is_foreign = e->Procedure.is_foreign;
bool is_export = e->Procedure.is_export;
- bool is_require_results = (pl->tags & ProcTag_require_results) != 0;
if (e->pkg != nullptr && e->token.string == "main") {
if (pt->param_count != 0 ||
@@ -714,10 +713,10 @@ void check_proc_decl(CheckerContext *ctx, Entity *e, DeclInfo *d) {
}
}
- if (pt->result_count == 0 && is_require_results) {
- error(pl->type, "'#require_results' is not needed on a procedure with no results");
+ if (pt->result_count == 0 && ac.require_results) {
+ error(pl->type, "'require_results' is not needed on a procedure with no results");
} else {
- pt->require_results = is_require_results;
+ pt->require_results = ac.require_results;
}
if (ac.link_name.len > 0) {
diff --git a/src/checker.cpp b/src/checker.cpp
index 9fa6d4555..b00b4bbac 100644
--- a/src/checker.cpp
+++ b/src/checker.cpp
@@ -2187,6 +2187,12 @@ DECL_ATTRIBUTE_PROC(proc_decl_attribute) {
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));
+ }
+ ac->require_results = true;
+ return true;
}
return false;
}
diff --git a/src/checker.hpp b/src/checker.hpp
index a37a87b87..58cb01a82 100644
--- a/src/checker.hpp
+++ b/src/checker.hpp
@@ -97,6 +97,7 @@ struct DeferredProcedure {
struct AttributeContext {
bool is_export;
bool is_static;
+ bool require_results;
String link_name;
String link_prefix;
isize init_expr_list_count;
diff --git a/src/parser.cpp b/src/parser.cpp
index 34a42ba3d..e92489020 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -1855,7 +1855,7 @@ Ast *parse_operand(AstFile *f, bool lhs) {
}
if (tags != 0) {
- syntax_error(token, "A procedure type cannot have tags");
+ syntax_error(token, "A procedure type cannot have suffix tags");
}
return type;
@@ -2828,6 +2828,10 @@ Ast *parse_proc_type(AstFile *f, Token proc_token) {
u64 tags = 0;
parse_proc_tags(f, &tags);
+ if ((tags & ProcTag_require_results) != 0) {
+ syntax_error(f->curr_token, "#require_results has now been replaced as an attribute @(require_results) on the declaration");
+ tags &= ~ProcTag_require_results;
+ }
bool is_generic = false;