| author | |
| committer | |
| log | 696567d9d7870e5bf640186193fe0b7fbccdb6b6 |
| tree | fc6318964c8536666512c9ae8f97c3a626ebadc2 |
| parent | 912c1c24c32799c63949fdf466fccd31f84a1aa1 |
also fixed existing occurrences3 files changed, 15 insertions(+), 4 deletions(-)
src-self-hosted/stage1.zig+3-3| ... | @@ -428,11 +428,11 @@ export fn stage2_DepTokenizer_next(self: *stage2_DepTokenizer) stage2_DepNextRes | ... | @@ -428,11 +428,11 @@ export fn stage2_DepTokenizer_next(self: *stage2_DepTokenizer) stage2_DepNextRes |
| 428 | }; | 428 | }; |
| 429 | } | 429 | } |
| 430 | 430 | ||
| 431 | export const stage2_DepTokenizer = extern struct { | 431 | const stage2_DepTokenizer = extern struct { |
| 432 | handle: *DepTokenizer, | 432 | handle: *DepTokenizer, |
| 433 | }; | 433 | }; |
| 434 | 434 | ||
| 435 | export const stage2_DepNextResult = extern struct { | 435 | const stage2_DepNextResult = extern struct { |
| 436 | type_id: TypeId, | 436 | type_id: TypeId, |
| 437 | 437 | ||
| 438 | // when type_id == error --> error text | 438 | // when type_id == error --> error text |
| ... | @@ -441,7 +441,7 @@ export const stage2_DepNextResult = extern struct { | ... | @@ -441,7 +441,7 @@ export const stage2_DepNextResult = extern struct { |
| 441 | // when type_id == prereq --> prereq pathname | 441 | // when type_id == prereq --> prereq pathname |
| 442 | textz: [*]const u8, | 442 | textz: [*]const u8, |
| 443 | 443 | ||
| 444 | export const TypeId = extern enum { | 444 | const TypeId = extern enum { |
| 445 | error_, | 445 | error_, |
| 446 | null_, | 446 | null_, |
| 447 | target, | 447 | target, |
src/analyze.cpp+11| ... | @@ -3773,6 +3773,16 @@ ZigVar *add_variable(CodeGen *g, AstNode *source_node, Scope *parent_scope, Buf | ... | @@ -3773,6 +3773,16 @@ ZigVar *add_variable(CodeGen *g, AstNode *source_node, Scope *parent_scope, Buf |
| 3773 | return variable_entry; | 3773 | return variable_entry; |
| 3774 | } | 3774 | } |
| 3775 | 3775 | ||
| 3776 | static void validate_export_var_type(CodeGen *g, ZigType* type, AstNode *source_node) { | ||
| 3777 | switch (type->id) { | ||
| 3778 | case ZigTypeIdMetaType: | ||
| 3779 | add_node_error(g, source_node, buf_sprintf("cannot export variable of type 'type'")); | ||
| 3780 | break; | ||
| 3781 | default: | ||
| 3782 | break; | ||
| 3783 | } | ||
| 3784 | } | ||
| 3785 | |||
| 3776 | static void resolve_decl_var(CodeGen *g, TldVar *tld_var, bool allow_lazy) { | 3786 | static void resolve_decl_var(CodeGen *g, TldVar *tld_var, bool allow_lazy) { |
| 3777 | AstNode *source_node = tld_var->base.source_node; | 3787 | AstNode *source_node = tld_var->base.source_node; |
| 3778 | AstNodeVariableDeclaration *var_decl = &source_node->data.variable_declaration; | 3788 | AstNodeVariableDeclaration *var_decl = &source_node->data.variable_declaration; |
| ... | @@ -3862,6 +3872,7 @@ static void resolve_decl_var(CodeGen *g, TldVar *tld_var, bool allow_lazy) { | ... | @@ -3862,6 +3872,7 @@ static void resolve_decl_var(CodeGen *g, TldVar *tld_var, bool allow_lazy) { |
| 3862 | } | 3872 | } |
| 3863 | 3873 | ||
| 3864 | if (is_export) { | 3874 | if (is_export) { |
| 3875 | validate_export_var_type(g, type, source_node); | ||
| 3865 | add_var_export(g, tld_var->var, tld_var->var->name, GlobalLinkageIdStrong); | 3876 | add_var_export(g, tld_var->var, tld_var->var->name, GlobalLinkageIdStrong); |
| 3866 | } | 3877 | } |
| 3867 | 3878 |
test/gen_h.zig+1-1| ... | @@ -74,7 +74,7 @@ pub fn addCases(cases: *tests.GenHContext) void { | ... | @@ -74,7 +74,7 @@ pub fn addCases(cases: *tests.GenHContext) void { |
| 74 | ); | 74 | ); |
| 75 | 75 | ||
| 76 | cases.add("declare opaque type", | 76 | cases.add("declare opaque type", |
| 77 | \\export const Foo = @OpaqueType(); | 77 | \\const Foo = @OpaqueType(); |
| 78 | \\ | 78 | \\ |
| 79 | \\export fn entry(foo: ?*Foo) void { } | 79 | \\export fn entry(foo: ?*Foo) void { } |
| 80 | , | 80 | , |