llvm: avoid undefined values by ensuring the StackTrace decl is analyzed

The test builds an object file to prevent StackTrace from already having
been analyzed by other code.

Fixes #13030
This commit is contained in:
Jacob Young 2022-10-01 04:01:35 -04:00
parent d9490a4340
commit 8b66443d50
4 changed files with 29 additions and 0 deletions

View File

@ -2335,6 +2335,7 @@ pub const Object = struct {
const stack_trace_decl = builtin_namespace.decls
.getKeyAdapted(stack_trace_str, Module.DeclAdapter{ .mod = mod }).?;
mod.ensureDeclAnalyzed(stack_trace_decl) catch unreachable;
return mod.declPtr(stack_trace_decl).val.toType(undefined);
}
};

View File

@ -97,4 +97,6 @@ pub fn addCases(cases: *tests.StandaloneContext) void {
// Disabled due to tripping LLVM 13 assertion:
// https://github.com/ziglang/zig/issues/12015
//cases.add("tools/update_spirv_features.zig");
cases.addBuildFile("test/standalone/issue_13030/build.zig", .{ .build_modes = true });
}

View File

@ -0,0 +1,18 @@
const std = @import("std");
const builtin = @import("builtin");
const Builder = std.build.Builder;
const CrossTarget = std.zig.CrossTarget;
pub fn build(b: *Builder) void {
const mode = b.standardReleaseOptions();
const target = b.standardTargetOptions(.{});
const obj = b.addObject("main", "main.zig");
obj.setBuildMode(mode);
obj.setTarget(target);
b.default_step.dependOn(&obj.step);
const test_step = b.step("test", "Test the program");
test_step.dependOn(&obj.step);
}

View File

@ -0,0 +1,8 @@
const std = @import("std");
fn a() error{}!void {}
fn b() std.meta.FnPtr(fn () error{}!void) {
return &a;
}
export fn c() void {
_ = b();
}