mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
@deprecated: remove per-module flag in Build
This implementation looks at the builder of each module in the build graph instead of storing a boolean for each module.
This commit is contained in:
parent
e3da2852f4
commit
25790e95f1
6 changed files with 16 additions and 22 deletions
|
|
@ -94,7 +94,7 @@ available_deps: AvailableDeps,
|
|||
|
||||
release_mode: ReleaseMode,
|
||||
|
||||
// True only for the top-level builder.
|
||||
/// `true` only for the root `Build`; `false` for any `Build` belonging to a dependency.
|
||||
is_root: bool = false,
|
||||
|
||||
pub const ReleaseMode = enum {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ stack_check: ?bool,
|
|||
sanitize_c: ?bool,
|
||||
sanitize_thread: ?bool,
|
||||
fuzz: ?bool,
|
||||
allow_deprecated: ?bool,
|
||||
code_model: std.builtin.CodeModel,
|
||||
valgrind: ?bool,
|
||||
pic: ?bool,
|
||||
|
|
@ -285,7 +284,6 @@ pub fn init(
|
|||
.owner = owner,
|
||||
.root_source_file = if (options.root_source_file) |lp| lp.dupe(owner) else null,
|
||||
.import_table = .{},
|
||||
.allow_deprecated = owner.graph.allow_deprecated orelse !owner.is_root,
|
||||
.resolved_target = options.target,
|
||||
.optimize = options.optimize,
|
||||
.link_libc = options.link_libc,
|
||||
|
|
@ -560,7 +558,8 @@ pub fn appendZigProcessFlags(
|
|||
try addFlag(zig_args, m.red_zone, "-mred-zone", "-mno-red-zone");
|
||||
|
||||
if (m.root_source_file != null) {
|
||||
try addFlag(zig_args, m.allow_deprecated, "-fallow-deprecated", "-fno-allow-deprecated");
|
||||
const allow_deprecated = m.owner.graph.allow_deprecated orelse !m.owner.is_root;
|
||||
try addFlag(zig_args, allow_deprecated, "-fallow-deprecated", "-fno-allow-deprecated");
|
||||
}
|
||||
|
||||
if (m.dwarf_format) |dwarf_format| {
|
||||
|
|
|
|||
|
|
@ -4313,7 +4313,6 @@ fn findTrackableInner(
|
|||
.value_placeholder => unreachable,
|
||||
|
||||
// Once again, we start with the boring tags.
|
||||
.deprecated,
|
||||
.this,
|
||||
.ret_addr,
|
||||
.builtin_src,
|
||||
|
|
@ -4367,6 +4366,7 @@ fn findTrackableInner(
|
|||
.tuple_decl,
|
||||
.dbg_empty_stmt,
|
||||
.astgen_error,
|
||||
.deprecated,
|
||||
=> return,
|
||||
|
||||
// `@TypeOf` has a body.
|
||||
|
|
|
|||
9
test/cases/compile_errors/deprecated.zig
Normal file
9
test/cases/compile_errors/deprecated.zig
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
const bad = @deprecated(42);
|
||||
|
||||
pub export fn foo() usize {
|
||||
return bad;
|
||||
}
|
||||
|
||||
// error
|
||||
//
|
||||
// :1:13: error: found deprecated code
|
||||
|
|
@ -250,18 +250,4 @@ pub fn addCases(ctx: *Cases, b: *std.Build) !void {
|
|||
":1:5: error: expected expression, found 'invalid token'",
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
const case = ctx.obj("usage of deprecated code", b.graph.host);
|
||||
|
||||
case.addError(
|
||||
\\const bad = @deprecated(42);
|
||||
\\
|
||||
\\pub export fn foo() usize {
|
||||
\\ return bad;
|
||||
\\}
|
||||
, &[_][]const u8{
|
||||
":1:13: error: found deprecated code",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1199,13 +1199,13 @@ pub fn addCliTests(b: *std.Build) *Step {
|
|||
\\}
|
||||
;
|
||||
|
||||
var src_dir = std.fs.cwd().makeOpenPath(b.pathJoin(&.{ tmp_path, "src" }), .{}) catch unreachable;
|
||||
var src_dir = std.fs.cwd().makeOpenPath(b.pathJoin(&.{ tmp_path, "src" }), .{}) catch @panic("unable to create tmp path");
|
||||
defer src_dir.close();
|
||||
|
||||
var main = src_dir.createFile("main.zig", .{}) catch unreachable;
|
||||
var main = src_dir.createFile("main.zig", .{}) catch @panic("unable to create main.zig");
|
||||
defer main.close();
|
||||
|
||||
main.writeAll(new_main_src) catch unreachable;
|
||||
main.writeAll(new_main_src) catch @panic("unable to write to main.zig");
|
||||
}
|
||||
|
||||
const init_exe = b.addSystemCommand(&.{ b.graph.zig_exe, "init" });
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue