diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-11-30 00:25:52 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-11-30 00:25:52 -0500 |
| commit | 85e1e3b95f1f1699a842a5e889d8987692a829a4 (patch) | |
| tree | 74eff09f778dafe1b77ea1e1ec764b3ade3b4eb8 /src/analyze.cpp | |
| parent | f980c29306ac9435662bde6fb5557ca0c6d98310 (diff) | |
| parent | 6ebd26f3dbaf54230f24118043fe91d1f09f9e8e (diff) | |
| download | zig-85e1e3b95f1f1699a842a5e889d8987692a829a4.tar.gz zig-85e1e3b95f1f1699a842a5e889d8987692a829a4.zip | |
Merge pull request #3284 from Sahnvour/export_variables
Improved support for exporting variables
Diffstat (limited to 'src/analyze.cpp')
| -rw-r--r-- | src/analyze.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp index 894b2416f1..c0d2d636ef 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -3792,6 +3792,16 @@ ZigVar *add_variable(CodeGen *g, AstNode *source_node, Scope *parent_scope, Buf return variable_entry; } +static void validate_export_var_type(CodeGen *g, ZigType* type, AstNode *source_node) { + switch (type->id) { + case ZigTypeIdMetaType: + add_node_error(g, source_node, buf_sprintf("cannot export variable of type 'type'")); + break; + default: + break; + } +} + static void resolve_decl_var(CodeGen *g, TldVar *tld_var, bool allow_lazy) { AstNode *source_node = tld_var->base.source_node; AstNodeVariableDeclaration *var_decl = &source_node->data.variable_declaration; @@ -3881,6 +3891,7 @@ static void resolve_decl_var(CodeGen *g, TldVar *tld_var, bool allow_lazy) { } if (is_export) { + validate_export_var_type(g, type, source_node); add_var_export(g, tld_var->var, tld_var->var->name, GlobalLinkageIdStrong); } |
