mirror of
https://github.com/ziglang/zig.git
synced 2026-01-20 22:35:24 +00:00
Make sure @export symbol name is not empty
This commit is contained in:
parent
c1f3766f1c
commit
49771f356f
@ -16766,6 +16766,12 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio
|
||||
if (!symbol_name)
|
||||
return ira->codegen->invalid_instruction;
|
||||
|
||||
if (buf_len(symbol_name) < 1) {
|
||||
ir_add_error(ira, name_inst,
|
||||
buf_sprintf("exported symbol name cannot be empty"));
|
||||
return ira->codegen->invalid_instruction;
|
||||
}
|
||||
|
||||
GlobalLinkageId global_linkage_id;
|
||||
if (!ir_resolve_global_linkage(ira, linkage_inst, &global_linkage_id))
|
||||
return ira->codegen->invalid_instruction;
|
||||
|
||||
@ -2,6 +2,15 @@ const tests = @import("tests.zig");
|
||||
const builtin = @import("builtin");
|
||||
|
||||
pub fn addCases(cases: *tests.CompileErrorContext) void {
|
||||
cases.addTest("@export with empty name string",
|
||||
\\pub export fn entry() void { }
|
||||
\\comptime {
|
||||
\\ @export(entry, .{ .name = "" });
|
||||
\\}
|
||||
, &[_][]const u8{
|
||||
"tmp.zig:3:5: error: exported symbol name cannot be empty",
|
||||
});
|
||||
|
||||
cases.addTest("switch ranges endpoints are validated",
|
||||
\\pub export fn entry() void {
|
||||
\\ var x: i32 = 0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user