diff options
| author | gingerBill <bill@gingerbill.org> | 2017-10-15 16:05:42 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2017-10-15 16:05:42 +0100 |
| commit | 3d8bf36a304f3500840d4e2a990e78d15da70cb1 (patch) | |
| tree | 718153c089e1a959510af7fc259b5b66a1589fb1 /src/check_decl.cpp | |
| parent | 85f7c2d040e44e09c77da86b42aaf172666b73cf (diff) | |
`foreign export` block
```
foreign export {
my_i32: i32;
my_foo :: proc() -> i32 {
return 123;
}
}
```
Diffstat (limited to 'src/check_decl.cpp')
| -rw-r--r-- | src/check_decl.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/check_decl.cpp b/src/check_decl.cpp index 401722148..f43d23c1c 100644 --- a/src/check_decl.cpp +++ b/src/check_decl.cpp @@ -425,9 +425,9 @@ void check_proc_decl(Checker *c, Entity *e, DeclInfo *d) { TypeProc *pt = &proc_type->Proc; - bool is_foreign = (pl->tags & ProcTag_foreign) != 0; + bool is_foreign = e->Procedure.is_foreign; + bool is_export = (e->flags & EntityFlag_ForeignExport) != 0; bool is_link_name = (pl->tags & ProcTag_link_name) != 0; - bool is_export = (pl->tags & ProcTag_export) != 0; bool is_inline = (pl->tags & ProcTag_inline) != 0; bool is_no_inline = (pl->tags & ProcTag_no_inline) != 0; bool is_require_results = (pl->tags & ProcTag_require_results) != 0; @@ -489,7 +489,11 @@ void check_proc_decl(Checker *c, Entity *e, DeclInfo *d) { check_procedure_later(c, c->curr_ast_file, e->token, d, proc_type, pl->body, pl->tags); } } else if (!is_foreign) { - error(e->token, "Only a foreign procedure cannot have a body"); + if (e->flags & EntityFlag_ForeignExport) { + error(e->token, "Foreign export procedures must have a body"); + } else { + error(e->token, "Only a foreign procedure cannot have a body"); + } } if (pt->result_count == 0 && is_require_results) { |