From 8a5818535b83ba87849cb09de9f1ccd32e8bb480 Mon Sep 17 00:00:00 2001 From: Nick Cernis Date: Sat, 12 Nov 2022 20:03:24 +0100 Subject: Make invalidFmtError public and use in place of compileErrors for bad format strings (#13526) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Export invalidFmtErr To allow consistent use of "invalid format string" compile error response for badly formatted format strings. See https://github.com/ziglang/zig/pull/13489#issuecomment-1311759340. * Replace format compile errors with invalidFmtErr - Provides more consistent compile errors. - Gives user info about the type of the badly formated value. * Rename invalidFmtErr as invalidFmtError For consistency. Zig seems to use “Error” more often than “Err”. * std: add invalid format string checks to remaining custom formatters * pass reference-trace to comp when building build file; fix checkobjectstep --- src/main.zig | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/main.zig b/src/main.zig index d0edbbed6d..71325b18d9 100644 --- a/src/main.zig +++ b/src/main.zig @@ -3744,6 +3744,7 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi var override_global_cache_dir: ?[]const u8 = try optionalStringEnvVar(arena, "ZIG_GLOBAL_CACHE_DIR"); var override_local_cache_dir: ?[]const u8 = try optionalStringEnvVar(arena, "ZIG_LOCAL_CACHE_DIR"); var child_argv = std.ArrayList([]const u8).init(arena); + var reference_trace: ?u32 = null; const argv_index_exe = child_argv.items.len; _ = try child_argv.addOne(); @@ -3795,10 +3796,16 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi try child_argv.append(arg); } else if (mem.eql(u8, arg, "-freference-trace")) { try child_argv.append(arg); + reference_trace = 256; } else if (mem.startsWith(u8, arg, "-freference-trace=")) { try child_argv.append(arg); + const num = arg["-freference-trace=".len..]; + reference_trace = std.fmt.parseUnsigned(u32, num, 10) catch |err| { + fatal("unable to parse reference_trace count '{s}': {s}", .{ num, @errorName(err) }); + }; } else if (mem.eql(u8, arg, "-fno-reference-trace")) { try child_argv.append(arg); + reference_trace = null; } } try child_argv.append(arg); @@ -3932,6 +3939,7 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi .thread_pool = &thread_pool, .use_stage1 = use_stage1, .cache_mode = .whole, + .reference_trace = reference_trace, }) catch |err| { fatal("unable to create compilation: {s}", .{@errorName(err)}); }; -- cgit v1.2.3