| author | |
| committer | |
| log | 49771f356fddda873405da2cc6aaffb2758abcbc |
| tree | 80cb06256413e341d3cf813ded45d2dac91afb92 |
| parent | c1f3766f1c1a528ff24c24429298ff8ac162909f |
2 files changed, 15 insertions(+), 0 deletions(-)
src/ir.cpp+6| ... | @@ -16766,6 +16766,12 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio | ... | @@ -16766,6 +16766,12 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio |
| 16766 | if (!symbol_name) | 16766 | if (!symbol_name) |
| 16767 | return ira->codegen->invalid_instruction; | 16767 | return ira->codegen->invalid_instruction; |
| 16768 | 16768 | ||
| 16769 | if (buf_len(symbol_name) < 1) { | ||
| 16770 | ir_add_error(ira, name_inst, | ||
| 16771 | buf_sprintf("exported symbol name cannot be empty")); | ||
| 16772 | return ira->codegen->invalid_instruction; | ||
| 16773 | } | ||
| 16774 | |||
| 16769 | GlobalLinkageId global_linkage_id; | 16775 | GlobalLinkageId global_linkage_id; |
| 16770 | if (!ir_resolve_global_linkage(ira, linkage_inst, &global_linkage_id)) | 16776 | if (!ir_resolve_global_linkage(ira, linkage_inst, &global_linkage_id)) |
| 16771 | return ira->codegen->invalid_instruction; | 16777 | return ira->codegen->invalid_instruction; |
test/compile_errors.zig+9| ... | @@ -2,6 +2,15 @@ const tests = @import("tests.zig"); | ... | @@ -2,6 +2,15 @@ const tests = @import("tests.zig"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | 3 | ||
| 4 | pub fn addCases(cases: *tests.CompileErrorContext) void { | 4 | pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 5 | cases.addTest("@export with empty name string", | ||
| 6 | \\pub export fn entry() void { } | ||
| 7 | \\comptime { | ||
| 8 | \\ @export(entry, .{ .name = "" }); | ||
| 9 | \\} | ||
| 10 | , &[_][]const u8{ | ||
| 11 | "tmp.zig:3:5: error: exported symbol name cannot be empty", | ||
| 12 | }); | ||
| 13 | |||
| 5 | cases.addTest("switch ranges endpoints are validated", | 14 | cases.addTest("switch ranges endpoints are validated", |
| 6 | \\pub export fn entry() void { | 15 | \\pub export fn entry() void { |
| 7 | \\ var x: i32 = 0; | 16 | \\ var x: i32 = 0; |