| author | |
| committer | |
| log | 25790e95f1e8563f439bb13c460fdd4a46e68c43 |
| tree | a0e62a31174791bae27090d9baf730d4ee1155fd |
| parent | e3da2852f421ec2e7d568373b3f29030818e1d77 |
This implementation looks at the builder of each
module in the build graph instead of storing a
boolean for each module.6 files changed, 16 insertions(+), 22 deletions(-)
lib/std/Build.zig+1-1| ... | ... | @@ -94,7 +94,7 @@ available_deps: AvailableDeps, |
| 94 | 94 | |
| 95 | 95 | release_mode: ReleaseMode, |
| 96 | 96 | |
| 97 | // True only for the top-level builder. | |
| 97 | /// `true` only for the root `Build`; `false` for any `Build` belonging to a dependency. | |
| 98 | 98 | is_root: bool = false, |
| 99 | 99 | |
| 100 | 100 | pub const ReleaseMode = enum { |
lib/std/Build/Module.zig+2-3| ... | ... | @@ -25,7 +25,6 @@ stack_check: ?bool, |
| 25 | 25 | sanitize_c: ?bool, |
| 26 | 26 | sanitize_thread: ?bool, |
| 27 | 27 | fuzz: ?bool, |
| 28 | allow_deprecated: ?bool, | |
| 29 | 28 | code_model: std.builtin.CodeModel, |
| 30 | 29 | valgrind: ?bool, |
| 31 | 30 | pic: ?bool, |
| ... | ... | @@ -285,7 +284,6 @@ pub fn init( |
| 285 | 284 | .owner = owner, |
| 286 | 285 | .root_source_file = if (options.root_source_file) |lp| lp.dupe(owner) else null, |
| 287 | 286 | .import_table = .{}, |
| 288 | .allow_deprecated = owner.graph.allow_deprecated orelse !owner.is_root, | |
| 289 | 287 | .resolved_target = options.target, |
| 290 | 288 | .optimize = options.optimize, |
| 291 | 289 | .link_libc = options.link_libc, |
| ... | ... | @@ -560,7 +558,8 @@ pub fn appendZigProcessFlags( |
| 560 | 558 | try addFlag(zig_args, m.red_zone, "-mred-zone", "-mno-red-zone"); |
| 561 | 559 | |
| 562 | 560 | if (m.root_source_file != null) { |
| 563 | try addFlag(zig_args, m.allow_deprecated, "-fallow-deprecated", "-fno-allow-deprecated"); | |
| 561 | const allow_deprecated = m.owner.graph.allow_deprecated orelse !m.owner.is_root; | |
| 562 | try addFlag(zig_args, allow_deprecated, "-fallow-deprecated", "-fno-allow-deprecated"); | |
| 564 | 563 | } |
| 565 | 564 | |
| 566 | 565 | if (m.dwarf_format) |dwarf_format| { |
lib/std/zig/Zir.zig+1-1| ... | ... | @@ -4313,7 +4313,6 @@ fn findTrackableInner( |
| 4313 | 4313 | .value_placeholder => unreachable, |
| 4314 | 4314 | |
| 4315 | 4315 | // Once again, we start with the boring tags. |
| 4316 | .deprecated, | |
| 4317 | 4316 | .this, |
| 4318 | 4317 | .ret_addr, |
| 4319 | 4318 | .builtin_src, |
| ... | ... | @@ -4367,6 +4366,7 @@ fn findTrackableInner( |
| 4367 | 4366 | .tuple_decl, |
| 4368 | 4367 | .dbg_empty_stmt, |
| 4369 | 4368 | .astgen_error, |
| 4369 | .deprecated, | |
| 4370 | 4370 | => return, |
| 4371 | 4371 | |
| 4372 | 4372 | // `@TypeOf` has a body. |
test/cases/compile_errors/deprecated.zig created+9| ... | ... | @@ -0,0 +1,9 @@ |
| 1 | const bad = @deprecated(42); | |
| 2 | ||
| 3 | pub export fn foo() usize { | |
| 4 | return bad; | |
| 5 | } | |
| 6 | ||
| 7 | // error | |
| 8 | // | |
| 9 | // :1:13: error: found deprecated code |
test/compile_errors.zig-14| ... | ... | @@ -250,18 +250,4 @@ pub fn addCases(ctx: *Cases, b: *std.Build) !void { |
| 250 | 250 | ":1:5: error: expected expression, found 'invalid token'", |
| 251 | 251 | }); |
| 252 | 252 | } |
| 253 | ||
| 254 | { | |
| 255 | const case = ctx.obj("usage of deprecated code", b.graph.host); | |
| 256 | ||
| 257 | case.addError( | |
| 258 | \\const bad = @deprecated(42); | |
| 259 | \\ | |
| 260 | \\pub export fn foo() usize { | |
| 261 | \\ return bad; | |
| 262 | \\} | |
| 263 | , &[_][]const u8{ | |
| 264 | ":1:13: error: found deprecated code", | |
| 265 | }); | |
| 266 | } | |
| 267 | 253 | } |
test/tests.zig+3-3| ... | ... | @@ -1199,13 +1199,13 @@ pub fn addCliTests(b: *std.Build) *Step { |
| 1199 | 1199 | \\} |
| 1200 | 1200 | ; |
| 1201 | 1201 | |
| 1202 | var src_dir = std.fs.cwd().makeOpenPath(b.pathJoin(&.{ tmp_path, "src" }), .{}) catch unreachable; | |
| 1202 | var src_dir = std.fs.cwd().makeOpenPath(b.pathJoin(&.{ tmp_path, "src" }), .{}) catch @panic("unable to create tmp path"); | |
| 1203 | 1203 | defer src_dir.close(); |
| 1204 | 1204 | |
| 1205 | var main = src_dir.createFile("main.zig", .{}) catch unreachable; | |
| 1205 | var main = src_dir.createFile("main.zig", .{}) catch @panic("unable to create main.zig"); | |
| 1206 | 1206 | defer main.close(); |
| 1207 | 1207 | |
| 1208 | main.writeAll(new_main_src) catch unreachable; | |
| 1208 | main.writeAll(new_main_src) catch @panic("unable to write to main.zig"); | |
| 1209 | 1209 | } |
| 1210 | 1210 | |
| 1211 | 1211 | const init_exe = b.addSystemCommand(&.{ b.graph.zig_exe, "init" }); |