@@ -83,6 +83,7 @@ const Decl = Module.Decl;
83
83
const LazySrcLoc = Module .LazySrcLoc ;
84
84
const RangeSet = @import ("RangeSet.zig" );
85
85
const target_util = @import ("target.zig" );
86
+ const Package = @import ("Package.zig" );
86
87
87
88
pub const InstMap = std .AutoHashMapUnmanaged (Zir .Inst .Index , Air .Inst .Ref );
88
89
@@ -2167,23 +2168,26 @@ fn zirCImport(sema: *Sema, parent_block: *Scope.Block, inst: Zir.Inst.Index) Com
2167
2168
return sema .mod .fail (& child_block .base , src , "C import failed: {s}" , .{@errorName (err )});
2168
2169
2169
2170
if (c_import_res .errors .len != 0 ) {
2170
- const msg = try sema .mod .errMsg (& child_block .base , src , "C import failed" , .{});
2171
- errdefer msg .destroy (sema .gpa );
2171
+ const msg = msg : {
2172
+ const msg = try sema .mod .errMsg (& child_block .base , src , "C import failed" , .{});
2173
+ errdefer msg .destroy (sema .gpa );
2172
2174
2173
- if (! sema .mod .comp .bin_file .options .link_libc )
2174
- try sema .mod .errNote (& child_block .base , src , msg , "libc headers not available; compilation does not link against libc" , .{});
2175
+ if (! sema .mod .comp .bin_file .options .link_libc )
2176
+ try sema .mod .errNote (& child_block .base , src , msg , "libc headers not available; compilation does not link against libc" , .{});
2175
2177
2176
- for (c_import_res .errors ) | _ | {
2177
- // TODO integrate with LazySrcLoc
2178
- // try sema.mod.errNoteNonLazy(.{}, msg, "{s}", .{clang_err.msg_ptr[0..clang_err.msg_len]});
2179
- // if (clang_err.filename_ptr) |p| p[0..clang_err.filename_len] else "(no file)",
2180
- // clang_err.line + 1,
2181
- // clang_err.column + 1,
2182
- }
2183
- @import ("clang.zig" ).Stage2ErrorMsg .delete (c_import_res .errors .ptr , c_import_res .errors .len );
2178
+ for (c_import_res .errors ) | _ | {
2179
+ // TODO integrate with LazySrcLoc
2180
+ // try sema.mod.errNoteNonLazy(.{}, msg, "{s}", .{clang_err.msg_ptr[0..clang_err.msg_len]});
2181
+ // if (clang_err.filename_ptr) |p| p[0..clang_err.filename_len] else "(no file)",
2182
+ // clang_err.line + 1,
2183
+ // clang_err.column + 1,
2184
+ }
2185
+ @import ("clang.zig" ).Stage2ErrorMsg .delete (c_import_res .errors .ptr , c_import_res .errors .len );
2186
+ break :msg msg ;
2187
+ };
2184
2188
return sema .mod .failWithOwnedErrorMsg (& child_block .base , msg );
2185
2189
}
2186
- const c_import_pkg = @import ( " Package.zig" ) .create (
2190
+ const c_import_pkg = Package .create (
2187
2191
sema .gpa ,
2188
2192
null ,
2189
2193
c_import_res .out_zig_path ,
0 commit comments