ir: Avoid invalidating the decl_table iterator

Collect the declarations to resolve first and run resolve_top_level_decl
on them later.

Closes #4310
This commit is contained in:
LemonBoy
2020-02-16 20:19:30 +01:00
parent 59a243ce24
commit 6b74fd2e12
2 changed files with 37 additions and 18 deletions

View File

@@ -3,13 +3,13 @@ const builtin = @import("builtin");
const Target = @import("std").Target;
pub fn addCases(cases: *tests.CompileErrorContext) void {
cases.addTest("access of undefined pointer to array",
\\const ram_u32: *[4096]u32 = undefined;
\\export fn entry() void {
\\ @ptrCast(*u32, &(ram_u32[0])) = &(ram_u32[0]);
cases.addTest("",
\\const A = B;
\\test "Crash" {
\\ _ = @typeInfo(@This()).Struct.decls;
\\}
, &[_][]const u8{
"tmp.zig:3:29: error: use of undefined value here causes undefined behavior",
"tmp.zig:1:11: error: use of undeclared identifier 'B'",
});
cases.addTest("duplicate field in anonymous struct literal",