| author | |
| committer | |
| log | fff8eff2bd0cc36b192d0ab43b522161227c3c2d |
| tree | 13980a602ac4a993da81002010ef6e6fa65a2eea |
| parent | 8957b2707464a4dc7f0572bfc08fd104408bc8a3 |
9 files changed, 60 insertions(+), 2 deletions(-)
lib/std/zig/AstGen.zig+13| ... | ... | @@ -9695,6 +9695,19 @@ fn builtinCall( |
| 9695 | 9695 | .volatile_cast, |
| 9696 | 9696 | => return ptrCast(gz, scope, ri, node), |
| 9697 | 9697 | |
| 9698 | .deprecated => { | |
| 9699 | _ = try gz.addExtendedNodeSmall(.deprecated, node, 0); | |
| 9700 | switch (params.len) { | |
| 9701 | 0 => return .void_value, | |
| 9702 | 1 => return expr(gz, scope, ri, params[0]), | |
| 9703 | else => return astgen.failNode( | |
| 9704 | node, | |
| 9705 | "expected 0 or 1 argument, found {}", | |
| 9706 | .{params.len}, | |
| 9707 | ), | |
| 9708 | } | |
| 9709 | }, | |
| 9710 | ||
| 9698 | 9711 | // zig fmt: off |
| 9699 | 9712 | .has_decl => return hasDeclOrField(gz, scope, ri, node, params[0], params[1], .has_decl), |
| 9700 | 9713 | .has_field => return hasDeclOrField(gz, scope, ri, node, params[0], params[1], .has_field), |
lib/std/zig/AstRlAnnotate.zig+5-2| ... | ... | @@ -817,8 +817,6 @@ fn blockExpr(astrl: *AstRlAnnotate, parent_block: ?*Block, ri: ResultInfo, node: |
| 817 | 817 | } |
| 818 | 818 | |
| 819 | 819 | fn builtinCall(astrl: *AstRlAnnotate, block: ?*Block, ri: ResultInfo, node: Ast.Node.Index, args: []const Ast.Node.Index) !bool { |
| 820 | _ = ri; // Currently, no builtin consumes its result location. | |
| 821 | ||
| 822 | 820 | const tree = astrl.tree; |
| 823 | 821 | const main_tokens = tree.nodes.items(.main_token); |
| 824 | 822 | const builtin_token = main_tokens[node]; |
| ... | ... | @@ -828,6 +826,11 @@ fn builtinCall(astrl: *AstRlAnnotate, block: ?*Block, ri: ResultInfo, node: Ast. |
| 828 | 826 | if (expected != args.len) return false; |
| 829 | 827 | } |
| 830 | 828 | switch (info.tag) { |
| 829 | .deprecated => if (args.len >= 1) { | |
| 830 | return astrl.expr(args[0], block, ri); | |
| 831 | } else { | |
| 832 | return false; | |
| 833 | }, | |
| 831 | 834 | .import => return false, |
| 832 | 835 | .branch_hint => { |
| 833 | 836 | _ = try astrl.expr(args[0], block, ResultInfo.type_only); |
lib/std/zig/BuiltinFn.zig+9| ... | ... | @@ -121,6 +121,7 @@ pub const Tag = enum { |
| 121 | 121 | work_item_id, |
| 122 | 122 | work_group_size, |
| 123 | 123 | work_group_id, |
| 124 | deprecated, | |
| 124 | 125 | }; |
| 125 | 126 | |
| 126 | 127 | pub const EvalToError = enum { |
| ... | ... | @@ -1016,6 +1017,14 @@ pub const list = list: { |
| 1016 | 1017 | .illegal_outside_function = true, |
| 1017 | 1018 | }, |
| 1018 | 1019 | }, |
| 1020 | .{ | |
| 1021 | "@deprecated", | |
| 1022 | .{ | |
| 1023 | .tag = .deprecated, | |
| 1024 | .param_count = null, | |
| 1025 | .eval_to_error = .maybe, | |
| 1026 | }, | |
| 1027 | }, | |
| 1019 | 1028 | }); |
| 1020 | 1029 | }; |
| 1021 | 1030 |
lib/std/zig/Zir.zig+4| ... | ... | @@ -2112,6 +2112,9 @@ pub const Inst = struct { |
| 2112 | 2112 | /// any code may have gone here, avoiding false-positive "unreachable code" errors. |
| 2113 | 2113 | astgen_error, |
| 2114 | 2114 | |
| 2115 | /// `operand` is `src_node: i32`. | |
| 2116 | deprecated, | |
| 2117 | ||
| 2115 | 2118 | pub const InstData = struct { |
| 2116 | 2119 | opcode: Extended, |
| 2117 | 2120 | small: u16, |
| ... | ... | @@ -4310,6 +4313,7 @@ fn findTrackableInner( |
| 4310 | 4313 | .value_placeholder => unreachable, |
| 4311 | 4314 | |
| 4312 | 4315 | // Once again, we start with the boring tags. |
| 4316 | .deprecated, | |
| 4313 | 4317 | .this, |
| 4314 | 4318 | .ret_addr, |
| 4315 | 4319 | .builtin_src, |
src/Compilation.zig+1| ... | ... | @@ -869,6 +869,7 @@ pub const cache_helpers = struct { |
| 869 | 869 | hh.add(mod.sanitize_c); |
| 870 | 870 | hh.add(mod.sanitize_thread); |
| 871 | 871 | hh.add(mod.fuzz); |
| 872 | hh.add(mod.allow_deprecated); | |
| 872 | 873 | hh.add(mod.unwind_tables); |
| 873 | 874 | hh.add(mod.structured_cfg); |
| 874 | 875 | hh.add(mod.no_builtin); |
src/Package/Module.zig+11| ... | ... | @@ -27,6 +27,7 @@ red_zone: bool, |
| 27 | 27 | sanitize_c: bool, |
| 28 | 28 | sanitize_thread: bool, |
| 29 | 29 | fuzz: bool, |
| 30 | allow_deprecated: bool, | |
| 30 | 31 | unwind_tables: std.builtin.UnwindTables, |
| 31 | 32 | cc_argv: []const []const u8, |
| 32 | 33 | /// (SPIR-V) whether to generate a structured control flow graph or not |
| ... | ... | @@ -95,6 +96,7 @@ pub const CreateOptions = struct { |
| 95 | 96 | sanitize_c: ?bool = null, |
| 96 | 97 | sanitize_thread: ?bool = null, |
| 97 | 98 | fuzz: ?bool = null, |
| 99 | allow_deprecated: ?bool = null, | |
| 98 | 100 | structured_cfg: ?bool = null, |
| 99 | 101 | no_builtin: ?bool = null, |
| 100 | 102 | }; |
| ... | ... | @@ -234,6 +236,12 @@ pub fn create(arena: Allocator, options: CreateOptions) !*Package.Module { |
| 234 | 236 | break :b false; |
| 235 | 237 | }; |
| 236 | 238 | |
| 239 | const allow_deprecated = b: { | |
| 240 | if (options.inherited.allow_deprecated) |x| break :b x; | |
| 241 | if (options.parent) |p| break :b p.allow_deprecated; | |
| 242 | break :b false; | |
| 243 | }; | |
| 244 | ||
| 237 | 245 | const code_model = b: { |
| 238 | 246 | if (options.inherited.code_model) |x| break :b x; |
| 239 | 247 | if (options.parent) |p| break :b p.code_model; |
| ... | ... | @@ -380,6 +388,7 @@ pub fn create(arena: Allocator, options: CreateOptions) !*Package.Module { |
| 380 | 388 | .sanitize_c = sanitize_c, |
| 381 | 389 | .sanitize_thread = sanitize_thread, |
| 382 | 390 | .fuzz = fuzz, |
| 391 | .allow_deprecated = allow_deprecated, | |
| 383 | 392 | .unwind_tables = unwind_tables, |
| 384 | 393 | .cc_argv = options.cc_argv, |
| 385 | 394 | .structured_cfg = structured_cfg, |
| ... | ... | @@ -474,6 +483,7 @@ pub fn create(arena: Allocator, options: CreateOptions) !*Package.Module { |
| 474 | 483 | .sanitize_c = sanitize_c, |
| 475 | 484 | .sanitize_thread = sanitize_thread, |
| 476 | 485 | .fuzz = fuzz, |
| 486 | .allow_deprecated = allow_deprecated, | |
| 477 | 487 | .unwind_tables = unwind_tables, |
| 478 | 488 | .cc_argv = &.{}, |
| 479 | 489 | .structured_cfg = structured_cfg, |
| ... | ... | @@ -532,6 +542,7 @@ pub fn createLimited(gpa: Allocator, options: LimitedOptions) Allocator.Error!*P |
| 532 | 542 | .sanitize_c = undefined, |
| 533 | 543 | .sanitize_thread = undefined, |
| 534 | 544 | .fuzz = undefined, |
| 545 | .allow_deprecated = undefined, | |
| 535 | 546 | .unwind_tables = undefined, |
| 536 | 547 | .cc_argv = undefined, |
| 537 | 548 | .structured_cfg = undefined, |
src/Sema.zig+10| ... | ... | @@ -1091,6 +1091,7 @@ fn analyzeBodyInner( |
| 1091 | 1091 | const map = &sema.inst_map; |
| 1092 | 1092 | const tags = sema.code.instructions.items(.tag); |
| 1093 | 1093 | const datas = sema.code.instructions.items(.data); |
| 1094 | const mod = block.ownerModule(); | |
| 1094 | 1095 | |
| 1095 | 1096 | var crash_info = crash_report.prepAnalyzeBody(sema, block, body); |
| 1096 | 1097 | crash_info.push(); |
| ... | ... | @@ -1341,6 +1342,15 @@ fn analyzeBodyInner( |
| 1341 | 1342 | .extended => ext: { |
| 1342 | 1343 | const extended = datas[@intFromEnum(inst)].extended; |
| 1343 | 1344 | break :ext switch (extended.opcode) { |
| 1345 | .deprecated => { | |
| 1346 | if (!mod.allow_deprecated) { | |
| 1347 | const src_node: i32 = @bitCast(extended.operand); | |
| 1348 | const src = block.nodeOffset(src_node); | |
| 1349 | return sema.fail(block, src, "found deprecated code", .{}); | |
| 1350 | } | |
| 1351 | ||
| 1352 | break :ext .void_value; | |
| 1353 | }, | |
| 1344 | 1354 | // zig fmt: off |
| 1345 | 1355 | .struct_decl => try sema.zirStructDecl( block, extended, inst), |
| 1346 | 1356 | .enum_decl => try sema.zirEnumDecl( block, extended, inst), |
src/main.zig+6| ... | ... | @@ -520,6 +520,8 @@ const usage_build_generic = |
| 520 | 520 | \\ -fno-sanitize-thread Disable Thread Sanitizer |
| 521 | 521 | \\ -ffuzz Enable fuzz testing instrumentation |
| 522 | 522 | \\ -fno-fuzz Disable fuzz testing instrumentation |
| 523 | \\ -fallow-deprecated Allow usage of deprecated code | |
| 524 | \\ -fno-allow-deprecated Disallow usage of deprecated code | |
| 523 | 525 | \\ -funwind-tables Always produce unwind table entries for all functions |
| 524 | 526 | \\ -fasync-unwind-tables Always produce asynchronous unwind table entries for all functions |
| 525 | 527 | \\ -fno-unwind-tables Never produce unwind table entries |
| ... | ... | @@ -1454,6 +1456,10 @@ fn buildOutputType( |
| 1454 | 1456 | mod_opts.fuzz = true; |
| 1455 | 1457 | } else if (mem.eql(u8, arg, "-fno-fuzz")) { |
| 1456 | 1458 | mod_opts.fuzz = false; |
| 1459 | } else if (mem.eql(u8, arg, "-fallow-deprecated")) { | |
| 1460 | mod_opts.allow_deprecated = true; | |
| 1461 | } else if (mem.eql(u8, arg, "-fno-allow-deprecated")) { | |
| 1462 | mod_opts.allow_deprecated = false; | |
| 1457 | 1463 | } else if (mem.eql(u8, arg, "-fllvm")) { |
| 1458 | 1464 | create_module.opts.use_llvm = true; |
| 1459 | 1465 | } else if (mem.eql(u8, arg, "-fno-llvm")) { |
src/print_zir.zig+1| ... | ... | @@ -535,6 +535,7 @@ const Writer = struct { |
| 535 | 535 | .c_va_start, |
| 536 | 536 | .in_comptime, |
| 537 | 537 | .value_placeholder, |
| 538 | .deprecated, | |
| 538 | 539 | => try self.writeExtNode(stream, extended), |
| 539 | 540 | |
| 540 | 541 | .builtin_src => { |