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