| author | |
| committer | |
| log | c25ce5bba0d00283ad4de9077dba5a8d5255b619 |
| tree | cc4bdb8332acdde7b23bffacfc42bffaa6d35273 |
| parent | be944870298e4694e8ccb3f8c65a0bd152e26dad |
| parent | b2e94de3585e0a1242e3a5d6c8fd331da9f2d4f5 |
| signature |
introduce compile error for pointless discards22 files changed, 157 insertions(+), 140 deletions(-)
lib/std/Thread.zig-1| ... | @@ -404,7 +404,6 @@ fn callFn(comptime f: anytype, args: anytype) switch (Impl) { | ... | @@ -404,7 +404,6 @@ fn callFn(comptime f: anytype, args: anytype) switch (Impl) { |
| 404 | } | 404 | } |
| 405 | 405 | ||
| 406 | // pthreads don't support exit status, ignore value | 406 | // pthreads don't support exit status, ignore value |
| 407 | _ = status; | ||
| 408 | return default_value; | 407 | return default_value; |
| 409 | }, | 408 | }, |
| 410 | .ErrorUnion => |info| { | 409 | .ErrorUnion => |info| { |
lib/std/heap/general_purpose_allocator.zig-2| ... | @@ -582,8 +582,6 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { | ... | @@ -582,8 +582,6 @@ pub fn GeneralPurposeAllocator(comptime config: Config) type { |
| 582 | old_align: u29, | 582 | old_align: u29, |
| 583 | ret_addr: usize, | 583 | ret_addr: usize, |
| 584 | ) void { | 584 | ) void { |
| 585 | _ = old_align; | ||
| 586 | |||
| 587 | const entry = self.large_allocations.getEntry(@ptrToInt(old_mem.ptr)) orelse { | 585 | const entry = self.large_allocations.getEntry(@ptrToInt(old_mem.ptr)) orelse { |
| 588 | if (config.safety) { | 586 | if (config.safety) { |
| 589 | @panic("Invalid free"); | 587 | @panic("Invalid free"); |
lib/std/math.zig-1| ... | @@ -171,7 +171,6 @@ pub fn approxEqRel(comptime T: type, x: T, y: T, tolerance: T) bool { | ... | @@ -171,7 +171,6 @@ pub fn approxEqRel(comptime T: type, x: T, y: T, tolerance: T) bool { |
| 171 | } | 171 | } |
| 172 | 172 | ||
| 173 | pub fn approxEq(comptime T: type, x: T, y: T, tolerance: T) bool { | 173 | pub fn approxEq(comptime T: type, x: T, y: T, tolerance: T) bool { |
| 174 | _ = T; | ||
| 175 | _ = x; | 174 | _ = x; |
| 176 | _ = y; | 175 | _ = y; |
| 177 | _ = tolerance; | 176 | _ = tolerance; |
src/AstGen.zig+36-17| ... | @@ -2685,11 +2685,7 @@ fn genDefers( | ... | @@ -2685,11 +2685,7 @@ fn genDefers( |
| 2685 | } | 2685 | } |
| 2686 | } | 2686 | } |
| 2687 | 2687 | ||
| 2688 | fn checkUsed( | 2688 | fn checkUsed(gz: *GenZir, outer_scope: *Scope, inner_scope: *Scope) InnerError!void { |
| 2689 | gz: *GenZir, | ||
| 2690 | outer_scope: *Scope, | ||
| 2691 | inner_scope: *Scope, | ||
| 2692 | ) InnerError!void { | ||
| 2693 | const astgen = gz.astgen; | 2689 | const astgen = gz.astgen; |
| 2694 | 2690 | ||
| 2695 | var scope = inner_scope; | 2691 | var scope = inner_scope; |
| ... | @@ -2698,15 +2694,23 @@ fn checkUsed( | ... | @@ -2698,15 +2694,23 @@ fn checkUsed( |
| 2698 | .gen_zir => scope = scope.cast(GenZir).?.parent, | 2694 | .gen_zir => scope = scope.cast(GenZir).?.parent, |
| 2699 | .local_val => { | 2695 | .local_val => { |
| 2700 | const s = scope.cast(Scope.LocalVal).?; | 2696 | const s = scope.cast(Scope.LocalVal).?; |
| 2701 | if (!s.used) { | 2697 | if (s.used == 0 and s.discarded == 0) { |
| 2702 | try astgen.appendErrorTok(s.token_src, "unused {s}", .{@tagName(s.id_cat)}); | 2698 | try astgen.appendErrorTok(s.token_src, "unused {s}", .{@tagName(s.id_cat)}); |
| 2699 | } else if (s.used != 0 and s.discarded != 0) { | ||
| 2700 | try astgen.appendErrorTokNotes(s.discarded, "pointless discard of {s}", .{@tagName(s.id_cat)}, &[_]u32{ | ||
| 2701 | try gz.astgen.errNoteTok(s.used, "used here", .{}), | ||
| 2702 | }); | ||
| 2703 | } | 2703 | } |
| 2704 | scope = s.parent; | 2704 | scope = s.parent; |
| 2705 | }, | 2705 | }, |
| 2706 | .local_ptr => { | 2706 | .local_ptr => { |
| 2707 | const s = scope.cast(Scope.LocalPtr).?; | 2707 | const s = scope.cast(Scope.LocalPtr).?; |
| 2708 | if (!s.used) { | 2708 | if (s.used == 0 and s.discarded == 0) { |
| 2709 | try astgen.appendErrorTok(s.token_src, "unused {s}", .{@tagName(s.id_cat)}); | 2709 | try astgen.appendErrorTok(s.token_src, "unused {s}", .{@tagName(s.id_cat)}); |
| 2710 | } else if (s.used != 0 and s.discarded != 0) { | ||
| 2711 | try astgen.appendErrorTokNotes(s.discarded, "pointless discard of {s}", .{@tagName(s.id_cat)}, &[_]u32{ | ||
| 2712 | try gz.astgen.errNoteTok(s.used, "used here", .{}), | ||
| 2713 | }); | ||
| 2710 | } | 2714 | } |
| 2711 | scope = s.parent; | 2715 | scope = s.parent; |
| 2712 | }, | 2716 | }, |
| ... | @@ -6848,11 +6852,10 @@ fn localVarRef( | ... | @@ -6848,11 +6852,10 @@ fn localVarRef( |
| 6848 | scope: *Scope, | 6852 | scope: *Scope, |
| 6849 | rl: ResultLoc, | 6853 | rl: ResultLoc, |
| 6850 | ident: Ast.Node.Index, | 6854 | ident: Ast.Node.Index, |
| 6851 | ident_token: Ast.Node.Index, | 6855 | ident_token: Ast.TokenIndex, |
| 6852 | ) InnerError!Zir.Inst.Ref { | 6856 | ) InnerError!Zir.Inst.Ref { |
| 6853 | const astgen = gz.astgen; | 6857 | const astgen = gz.astgen; |
| 6854 | const gpa = astgen.gpa; | 6858 | const gpa = astgen.gpa; |
| 6855 | |||
| 6856 | const name_str_index = try astgen.identAsString(ident_token); | 6859 | const name_str_index = try astgen.identAsString(ident_token); |
| 6857 | var s = scope; | 6860 | var s = scope; |
| 6858 | var found_already: ?Ast.Node.Index = null; // we have found a decl with the same name already | 6861 | var found_already: ?Ast.Node.Index = null; // we have found a decl with the same name already |
| ... | @@ -6865,7 +6868,11 @@ fn localVarRef( | ... | @@ -6865,7 +6868,11 @@ fn localVarRef( |
| 6865 | if (local_val.name == name_str_index) { | 6868 | if (local_val.name == name_str_index) { |
| 6866 | // Locals cannot shadow anything, so we do not need to look for ambiguous | 6869 | // Locals cannot shadow anything, so we do not need to look for ambiguous |
| 6867 | // references in this case. | 6870 | // references in this case. |
| 6868 | local_val.used = true; | 6871 | if (rl == .discard) { |
| 6872 | local_val.discarded = ident_token; | ||
| 6873 | } else { | ||
| 6874 | local_val.used = ident_token; | ||
| 6875 | } | ||
| 6869 | 6876 | ||
| 6870 | const value_inst = try tunnelThroughClosure( | 6877 | const value_inst = try tunnelThroughClosure( |
| 6871 | gz, | 6878 | gz, |
| ... | @@ -6884,7 +6891,11 @@ fn localVarRef( | ... | @@ -6884,7 +6891,11 @@ fn localVarRef( |
| 6884 | .local_ptr => { | 6891 | .local_ptr => { |
| 6885 | const local_ptr = s.cast(Scope.LocalPtr).?; | 6892 | const local_ptr = s.cast(Scope.LocalPtr).?; |
| 6886 | if (local_ptr.name == name_str_index) { | 6893 | if (local_ptr.name == name_str_index) { |
| 6887 | local_ptr.used = true; | 6894 | if (rl == .discard) { |
| 6895 | local_ptr.discarded = ident_token; | ||
| 6896 | } else { | ||
| 6897 | local_ptr.used = ident_token; | ||
| 6898 | } | ||
| 6888 | 6899 | ||
| 6889 | // Can't close over a runtime variable | 6900 | // Can't close over a runtime variable |
| 6890 | if (num_namespaces_out != 0 and !local_ptr.maybe_comptime) { | 6901 | if (num_namespaces_out != 0 and !local_ptr.maybe_comptime) { |
| ... | @@ -7519,7 +7530,7 @@ fn builtinCall( | ... | @@ -7519,7 +7530,7 @@ fn builtinCall( |
| 7519 | .local_val => { | 7530 | .local_val => { |
| 7520 | const local_val = s.cast(Scope.LocalVal).?; | 7531 | const local_val = s.cast(Scope.LocalVal).?; |
| 7521 | if (local_val.name == decl_name) { | 7532 | if (local_val.name == decl_name) { |
| 7522 | local_val.used = true; | 7533 | local_val.used = ident_token; |
| 7523 | _ = try gz.addPlNode(.export_value, node, Zir.Inst.ExportValue{ | 7534 | _ = try gz.addPlNode(.export_value, node, Zir.Inst.ExportValue{ |
| 7524 | .operand = local_val.inst, | 7535 | .operand = local_val.inst, |
| 7525 | .options = try comptimeExpr(gz, scope, .{ .coerced_ty = .export_options_type }, params[1]), | 7536 | .options = try comptimeExpr(gz, scope, .{ .coerced_ty = .export_options_type }, params[1]), |
| ... | @@ -7533,7 +7544,7 @@ fn builtinCall( | ... | @@ -7533,7 +7544,7 @@ fn builtinCall( |
| 7533 | if (local_ptr.name == decl_name) { | 7544 | if (local_ptr.name == decl_name) { |
| 7534 | if (!local_ptr.maybe_comptime) | 7545 | if (!local_ptr.maybe_comptime) |
| 7535 | return astgen.failNode(params[0], "unable to export runtime-known value", .{}); | 7546 | return astgen.failNode(params[0], "unable to export runtime-known value", .{}); |
| 7536 | local_ptr.used = true; | 7547 | local_ptr.used = ident_token; |
| 7537 | const loaded = try gz.addUnNode(.load, local_ptr.ptr, node); | 7548 | const loaded = try gz.addUnNode(.load, local_ptr.ptr, node); |
| 7538 | _ = try gz.addPlNode(.export_value, node, Zir.Inst.ExportValue{ | 7549 | _ = try gz.addPlNode(.export_value, node, Zir.Inst.ExportValue{ |
| 7539 | .operand = loaded, | 7550 | .operand = loaded, |
| ... | @@ -10065,11 +10076,15 @@ const Scope = struct { | ... | @@ -10065,11 +10076,15 @@ const Scope = struct { |
| 10065 | inst: Zir.Inst.Ref, | 10076 | inst: Zir.Inst.Ref, |
| 10066 | /// Source location of the corresponding variable declaration. | 10077 | /// Source location of the corresponding variable declaration. |
| 10067 | token_src: Ast.TokenIndex, | 10078 | token_src: Ast.TokenIndex, |
| 10079 | /// Track the first identifer where it is referenced. | ||
| 10080 | /// 0 means never referenced. | ||
| 10081 | used: Ast.TokenIndex = 0, | ||
| 10082 | /// Track the identifier where it is discarded, like this `_ = foo;`. | ||
| 10083 | /// 0 means never discarded. | ||
| 10084 | discarded: Ast.TokenIndex = 0, | ||
| 10068 | /// String table index. | 10085 | /// String table index. |
| 10069 | name: u32, | 10086 | name: u32, |
| 10070 | id_cat: IdCat, | 10087 | id_cat: IdCat, |
| 10071 | /// Track whether the name has been referenced. | ||
| 10072 | used: bool = false, | ||
| 10073 | }; | 10088 | }; |
| 10074 | 10089 | ||
| 10075 | /// This could be a `const` or `var` local. It has a pointer instead of a value. | 10090 | /// This could be a `const` or `var` local. It has a pointer instead of a value. |
| ... | @@ -10084,14 +10099,18 @@ const Scope = struct { | ... | @@ -10084,14 +10099,18 @@ const Scope = struct { |
| 10084 | ptr: Zir.Inst.Ref, | 10099 | ptr: Zir.Inst.Ref, |
| 10085 | /// Source location of the corresponding variable declaration. | 10100 | /// Source location of the corresponding variable declaration. |
| 10086 | token_src: Ast.TokenIndex, | 10101 | token_src: Ast.TokenIndex, |
| 10102 | /// Track the first identifer where it is referenced. | ||
| 10103 | /// 0 means never referenced. | ||
| 10104 | used: Ast.TokenIndex = 0, | ||
| 10105 | /// Track the identifier where it is discarded, like this `_ = foo;`. | ||
| 10106 | /// 0 means never discarded. | ||
| 10107 | discarded: Ast.TokenIndex = 0, | ||
| 10087 | /// String table index. | 10108 | /// String table index. |
| 10088 | name: u32, | 10109 | name: u32, |
| 10089 | id_cat: IdCat, | 10110 | id_cat: IdCat, |
| 10090 | /// true means we find out during Sema whether the value is comptime. | 10111 | /// true means we find out during Sema whether the value is comptime. |
| 10091 | /// false means it is already known at AstGen the value is runtime-known. | 10112 | /// false means it is already known at AstGen the value is runtime-known. |
| 10092 | maybe_comptime: bool, | 10113 | maybe_comptime: bool, |
| 10093 | /// Track whether the name has been referenced. | ||
| 10094 | used: bool = false, | ||
| 10095 | }; | 10114 | }; |
| 10096 | 10115 | ||
| 10097 | const Defer = struct { | 10116 | const Defer = struct { |
src/Autodoc.zig-4| ... | @@ -2506,7 +2506,6 @@ fn walkInstruction( | ... | @@ -2506,7 +2506,6 @@ fn walkInstruction( |
| 2506 | try self.srcLocInfo(file, sn, parent_src) | 2506 | try self.srcLocInfo(file, sn, parent_src) |
| 2507 | else | 2507 | else |
| 2508 | parent_src; | 2508 | parent_src; |
| 2509 | _ = src_info; | ||
| 2510 | 2509 | ||
| 2511 | const decls_len = if (small.has_decls_len) blk: { | 2510 | const decls_len = if (small.has_decls_len) blk: { |
| 2512 | const decls_len = file.zir.extra[extra_index]; | 2511 | const decls_len = file.zir.extra[extra_index]; |
| ... | @@ -2627,7 +2626,6 @@ fn walkInstruction( | ... | @@ -2627,7 +2626,6 @@ fn walkInstruction( |
| 2627 | extra_index += 1; | 2626 | extra_index += 1; |
| 2628 | break :blk fields_len; | 2627 | break :blk fields_len; |
| 2629 | } else 0; | 2628 | } else 0; |
| 2630 | _ = fields_len; | ||
| 2631 | 2629 | ||
| 2632 | const decls_len = if (small.has_decls_len) blk: { | 2630 | const decls_len = if (small.has_decls_len) blk: { |
| 2633 | const decls_len = file.zir.extra[extra_index]; | 2631 | const decls_len = file.zir.extra[extra_index]; |
| ... | @@ -2759,7 +2757,6 @@ fn walkInstruction( | ... | @@ -2759,7 +2757,6 @@ fn walkInstruction( |
| 2759 | extra_index += 1; | 2757 | extra_index += 1; |
| 2760 | break :blk fields_len; | 2758 | break :blk fields_len; |
| 2761 | } else 0; | 2759 | } else 0; |
| 2762 | _ = fields_len; | ||
| 2763 | 2760 | ||
| 2764 | const decls_len = if (small.has_decls_len) blk: { | 2761 | const decls_len = if (small.has_decls_len) blk: { |
| 2765 | const decls_len = file.zir.extra[extra_index]; | 2762 | const decls_len = file.zir.extra[extra_index]; |
| ... | @@ -2901,7 +2898,6 @@ fn walkInstruction( | ... | @@ -2901,7 +2898,6 @@ fn walkInstruction( |
| 2901 | extra_index += 1; | 2898 | extra_index += 1; |
| 2902 | break :blk fields_len; | 2899 | break :blk fields_len; |
| 2903 | } else 0; | 2900 | } else 0; |
| 2904 | _ = fields_len; | ||
| 2905 | 2901 | ||
| 2906 | const decls_len = if (small.has_decls_len) blk: { | 2902 | const decls_len = if (small.has_decls_len) blk: { |
| 2907 | const decls_len = file.zir.extra[extra_index]; | 2903 | const decls_len = file.zir.extra[extra_index]; |
src/Sema.zig+11-15| ... | @@ -17575,30 +17575,30 @@ fn zirIntToPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17575,30 +17575,30 @@ fn zirIntToPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17575 | const operand_coerced = try sema.coerce(block, Type.usize, operand_res, operand_src); | 17575 | const operand_coerced = try sema.coerce(block, Type.usize, operand_res, operand_src); |
| 17576 | 17576 | ||
| 17577 | const type_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; | 17577 | const type_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; |
| 17578 | const type_res = try sema.resolveType(block, src, extra.lhs); | 17578 | const ptr_ty = try sema.resolveType(block, src, extra.lhs); |
| 17579 | try sema.checkPtrType(block, type_src, type_res); | 17579 | const elem_ty = ptr_ty.elemType2(); |
| 17580 | try sema.resolveTypeLayout(block, src, type_res.elemType2()); | 17580 | try sema.checkPtrType(block, type_src, ptr_ty); |
| 17581 | const ptr_align = type_res.ptrAlignment(sema.mod.getTarget()); | ||
| 17582 | const target = sema.mod.getTarget(); | 17581 | const target = sema.mod.getTarget(); |
| 17582 | const ptr_align = try ptr_ty.ptrAlignmentAdvanced(target, sema.kit(block, src)); | ||
| 17583 | 17583 | ||
| 17584 | if (try sema.resolveDefinedValue(block, operand_src, operand_coerced)) |val| { | 17584 | if (try sema.resolveDefinedValue(block, operand_src, operand_coerced)) |val| { |
| 17585 | const addr = val.toUnsignedInt(target); | 17585 | const addr = val.toUnsignedInt(target); |
| 17586 | if (!type_res.isAllowzeroPtr() and addr == 0) | 17586 | if (!ptr_ty.isAllowzeroPtr() and addr == 0) |
| 17587 | return sema.fail(block, operand_src, "pointer type '{}' does not allow address zero", .{type_res.fmt(sema.mod)}); | 17587 | return sema.fail(block, operand_src, "pointer type '{}' does not allow address zero", .{ptr_ty.fmt(sema.mod)}); |
| 17588 | if (addr != 0 and addr % ptr_align != 0) | 17588 | if (addr != 0 and addr % ptr_align != 0) |
| 17589 | return sema.fail(block, operand_src, "pointer type '{}' requires aligned address", .{type_res.fmt(sema.mod)}); | 17589 | return sema.fail(block, operand_src, "pointer type '{}' requires aligned address", .{ptr_ty.fmt(sema.mod)}); |
| 17590 | 17590 | ||
| 17591 | const val_payload = try sema.arena.create(Value.Payload.U64); | 17591 | const val_payload = try sema.arena.create(Value.Payload.U64); |
| 17592 | val_payload.* = .{ | 17592 | val_payload.* = .{ |
| 17593 | .base = .{ .tag = .int_u64 }, | 17593 | .base = .{ .tag = .int_u64 }, |
| 17594 | .data = addr, | 17594 | .data = addr, |
| 17595 | }; | 17595 | }; |
| 17596 | return sema.addConstant(type_res, Value.initPayload(&val_payload.base)); | 17596 | return sema.addConstant(ptr_ty, Value.initPayload(&val_payload.base)); |
| 17597 | } | 17597 | } |
| 17598 | 17598 | ||
| 17599 | try sema.requireRuntimeBlock(block, src, operand_src); | 17599 | try sema.requireRuntimeBlock(block, src, operand_src); |
| 17600 | if (block.wantSafety() and try sema.typeHasRuntimeBits(block, sema.src, type_res.elemType2())) { | 17600 | if (block.wantSafety() and try sema.typeHasRuntimeBits(block, sema.src, elem_ty)) { |
| 17601 | if (!type_res.isAllowzeroPtr()) { | 17601 | if (!ptr_ty.isAllowzeroPtr()) { |
| 17602 | const is_non_zero = try block.addBinOp(.cmp_neq, operand_coerced, .zero_usize); | 17602 | const is_non_zero = try block.addBinOp(.cmp_neq, operand_coerced, .zero_usize); |
| 17603 | try sema.addSafetyCheck(block, is_non_zero, .cast_to_null); | 17603 | try sema.addSafetyCheck(block, is_non_zero, .cast_to_null); |
| 17604 | } | 17604 | } |
| ... | @@ -17618,7 +17618,7 @@ fn zirIntToPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai | ... | @@ -17618,7 +17618,7 @@ fn zirIntToPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 17618 | try sema.addSafetyCheck(block, is_aligned, .incorrect_alignment); | 17618 | try sema.addSafetyCheck(block, is_aligned, .incorrect_alignment); |
| 17619 | } | 17619 | } |
| 17620 | } | 17620 | } |
| 17621 | return block.addBitCast(type_res, operand_coerced); | 17621 | return block.addBitCast(ptr_ty, operand_coerced); |
| 17622 | } | 17622 | } |
| 17623 | 17623 | ||
| 17624 | fn zirErrSetCast(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!Air.Inst.Ref { | 17624 | fn zirErrSetCast(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData) CompileError!Air.Inst.Ref { |
| ... | @@ -19670,8 +19670,6 @@ fn zirMemcpy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void | ... | @@ -19670,8 +19670,6 @@ fn zirMemcpy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void |
| 19670 | if (try sema.resolveDefinedValue(block, src_src, src_ptr)) |src_ptr_val| { | 19670 | if (try sema.resolveDefinedValue(block, src_src, src_ptr)) |src_ptr_val| { |
| 19671 | if (!src_ptr_val.isComptimeMutablePtr()) break :rs src_src; | 19671 | if (!src_ptr_val.isComptimeMutablePtr()) break :rs src_src; |
| 19672 | if (try sema.resolveDefinedValue(block, len_src, len)) |len_val| { | 19672 | if (try sema.resolveDefinedValue(block, len_src, len)) |len_val| { |
| 19673 | _ = dest_ptr_val; | ||
| 19674 | _ = src_ptr_val; | ||
| 19675 | _ = len_val; | 19673 | _ = len_val; |
| 19676 | return sema.fail(block, src, "TODO: Sema.zirMemcpy at comptime", .{}); | 19674 | return sema.fail(block, src, "TODO: Sema.zirMemcpy at comptime", .{}); |
| 19677 | } else break :rs len_src; | 19675 | } else break :rs len_src; |
| ... | @@ -19713,7 +19711,6 @@ fn zirMemset(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void | ... | @@ -19713,7 +19711,6 @@ fn zirMemset(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!void |
| 19713 | if (!ptr_val.isComptimeMutablePtr()) break :rs dest_src; | 19711 | if (!ptr_val.isComptimeMutablePtr()) break :rs dest_src; |
| 19714 | if (try sema.resolveDefinedValue(block, len_src, len)) |len_val| { | 19712 | if (try sema.resolveDefinedValue(block, len_src, len)) |len_val| { |
| 19715 | if (try sema.resolveMaybeUndefVal(block, value_src, value)) |val| { | 19713 | if (try sema.resolveMaybeUndefVal(block, value_src, value)) |val| { |
| 19716 | _ = ptr_val; | ||
| 19717 | _ = len_val; | 19714 | _ = len_val; |
| 19718 | _ = val; | 19715 | _ = val; |
| 19719 | return sema.fail(block, src, "TODO: Sema.zirMemset at comptime", .{}); | 19716 | return sema.fail(block, src, "TODO: Sema.zirMemset at comptime", .{}); |
| ... | @@ -19941,7 +19938,6 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A | ... | @@ -19941,7 +19938,6 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A |
| 19941 | if (val.tag() == .generic_poison) { | 19938 | if (val.tag() == .generic_poison) { |
| 19942 | break :blk FuncLinkSection{ .generic = {} }; | 19939 | break :blk FuncLinkSection{ .generic = {} }; |
| 19943 | } | 19940 | } |
| 19944 | _ = val; | ||
| 19945 | return sema.fail(block, section_src, "TODO implement linksection on functions", .{}); | 19941 | return sema.fail(block, section_src, "TODO implement linksection on functions", .{}); |
| 19946 | } else if (extra.data.bits.has_section_ref) blk: { | 19942 | } else if (extra.data.bits.has_section_ref) blk: { |
| 19947 | const section_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]); | 19943 | const section_ref = @intToEnum(Zir.Inst.Ref, sema.code.extra[extra_index]); |
src/arch/aarch64/CodeGen.zig-3| ... | @@ -2581,7 +2581,6 @@ fn airErrUnionPayloadPtrSet(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -2581,7 +2581,6 @@ fn airErrUnionPayloadPtrSet(self: *Self, inst: Air.Inst.Index) !void { |
| 2581 | } | 2581 | } |
| 2582 | 2582 | ||
| 2583 | fn airErrReturnTrace(self: *Self, inst: Air.Inst.Index) !void { | 2583 | fn airErrReturnTrace(self: *Self, inst: Air.Inst.Index) !void { |
| 2584 | _ = inst; | ||
| 2585 | const result: MCValue = if (self.liveness.isUnused(inst)) | 2584 | const result: MCValue = if (self.liveness.isUnused(inst)) |
| 2586 | .dead | 2585 | .dead |
| 2587 | else | 2586 | else |
| ... | @@ -3614,7 +3613,6 @@ fn airRetLoad(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -3614,7 +3613,6 @@ fn airRetLoad(self: *Self, inst: Air.Inst.Index) !void { |
| 3614 | const ptr = try self.resolveInst(un_op); | 3613 | const ptr = try self.resolveInst(un_op); |
| 3615 | const ptr_ty = self.air.typeOf(un_op); | 3614 | const ptr_ty = self.air.typeOf(un_op); |
| 3616 | const ret_ty = self.fn_type.fnReturnType(); | 3615 | const ret_ty = self.fn_type.fnReturnType(); |
| 3617 | _ = ret_ty; | ||
| 3618 | 3616 | ||
| 3619 | switch (self.ret_mcv) { | 3617 | switch (self.ret_mcv) { |
| 3620 | .none => {}, | 3618 | .none => {}, |
| ... | @@ -5099,7 +5097,6 @@ fn lowerDeclRef(self: *Self, tv: TypedValue, decl_index: Module.Decl.Index) Inne | ... | @@ -5099,7 +5097,6 @@ fn lowerDeclRef(self: *Self, tv: TypedValue, decl_index: Module.Decl.Index) Inne |
| 5099 | } else { | 5097 | } else { |
| 5100 | return self.fail("TODO codegen non-ELF const Decl pointer", .{}); | 5098 | return self.fail("TODO codegen non-ELF const Decl pointer", .{}); |
| 5101 | } | 5099 | } |
| 5102 | _ = tv; | ||
| 5103 | } | 5100 | } |
| 5104 | 5101 | ||
| 5105 | fn lowerUnnamedConst(self: *Self, tv: TypedValue) InnerError!MCValue { | 5102 | fn lowerUnnamedConst(self: *Self, tv: TypedValue) InnerError!MCValue { |
src/arch/arm/CodeGen.zig-4| ... | @@ -2111,7 +2111,6 @@ fn airErrUnionPayloadPtrSet(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -2111,7 +2111,6 @@ fn airErrUnionPayloadPtrSet(self: *Self, inst: Air.Inst.Index) !void { |
| 2111 | } | 2111 | } |
| 2112 | 2112 | ||
| 2113 | fn airErrReturnTrace(self: *Self, inst: Air.Inst.Index) !void { | 2113 | fn airErrReturnTrace(self: *Self, inst: Air.Inst.Index) !void { |
| 2114 | _ = inst; | ||
| 2115 | const result: MCValue = if (self.liveness.isUnused(inst)) | 2114 | const result: MCValue = if (self.liveness.isUnused(inst)) |
| 2116 | .dead | 2115 | .dead |
| 2117 | else | 2116 | else |
| ... | @@ -3353,7 +3352,6 @@ fn divFloat( | ... | @@ -3353,7 +3352,6 @@ fn divFloat( |
| 3353 | ) InnerError!MCValue { | 3352 | ) InnerError!MCValue { |
| 3354 | _ = lhs_bind; | 3353 | _ = lhs_bind; |
| 3355 | _ = rhs_bind; | 3354 | _ = rhs_bind; |
| 3356 | _ = lhs_ty; | ||
| 3357 | _ = rhs_ty; | 3355 | _ = rhs_ty; |
| 3358 | _ = maybe_inst; | 3356 | _ = maybe_inst; |
| 3359 | 3357 | ||
| ... | @@ -3420,7 +3418,6 @@ fn divExact( | ... | @@ -3420,7 +3418,6 @@ fn divExact( |
| 3420 | ) InnerError!MCValue { | 3418 | ) InnerError!MCValue { |
| 3421 | _ = lhs_bind; | 3419 | _ = lhs_bind; |
| 3422 | _ = rhs_bind; | 3420 | _ = rhs_bind; |
| 3423 | _ = lhs_ty; | ||
| 3424 | _ = rhs_ty; | 3421 | _ = rhs_ty; |
| 3425 | _ = maybe_inst; | 3422 | _ = maybe_inst; |
| 3426 | 3423 | ||
| ... | @@ -3506,7 +3503,6 @@ fn modulo( | ... | @@ -3506,7 +3503,6 @@ fn modulo( |
| 3506 | ) InnerError!MCValue { | 3503 | ) InnerError!MCValue { |
| 3507 | _ = lhs_bind; | 3504 | _ = lhs_bind; |
| 3508 | _ = rhs_bind; | 3505 | _ = rhs_bind; |
| 3509 | _ = lhs_ty; | ||
| 3510 | _ = rhs_ty; | 3506 | _ = rhs_ty; |
| 3511 | _ = maybe_inst; | 3507 | _ = maybe_inst; |
| 3512 | 3508 |
src/arch/riscv64/CodeGen.zig-3| ... | @@ -1316,7 +1316,6 @@ fn airErrUnionPayloadPtrSet(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -1316,7 +1316,6 @@ fn airErrUnionPayloadPtrSet(self: *Self, inst: Air.Inst.Index) !void { |
| 1316 | } | 1316 | } |
| 1317 | 1317 | ||
| 1318 | fn airErrReturnTrace(self: *Self, inst: Air.Inst.Index) !void { | 1318 | fn airErrReturnTrace(self: *Self, inst: Air.Inst.Index) !void { |
| 1319 | _ = inst; | ||
| 1320 | const result: MCValue = if (self.liveness.isUnused(inst)) | 1319 | const result: MCValue = if (self.liveness.isUnused(inst)) |
| 1321 | .dead | 1320 | .dead |
| 1322 | else | 1321 | else |
| ... | @@ -1598,7 +1597,6 @@ fn airStructFieldPtrIndex(self: *Self, inst: Air.Inst.Index, index: u8) !void { | ... | @@ -1598,7 +1597,6 @@ fn airStructFieldPtrIndex(self: *Self, inst: Air.Inst.Index, index: u8) !void { |
| 1598 | return self.structFieldPtr(ty_op.operand, ty_op.ty, index); | 1597 | return self.structFieldPtr(ty_op.operand, ty_op.ty, index); |
| 1599 | } | 1598 | } |
| 1600 | fn structFieldPtr(self: *Self, operand: Air.Inst.Ref, ty: Air.Inst.Ref, index: u32) !void { | 1599 | fn structFieldPtr(self: *Self, operand: Air.Inst.Ref, ty: Air.Inst.Ref, index: u32) !void { |
| 1601 | _ = self; | ||
| 1602 | _ = operand; | 1600 | _ = operand; |
| 1603 | _ = ty; | 1601 | _ = ty; |
| 1604 | _ = index; | 1602 | _ = index; |
| ... | @@ -1615,7 +1613,6 @@ fn airStructFieldVal(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -1615,7 +1613,6 @@ fn airStructFieldVal(self: *Self, inst: Air.Inst.Index) !void { |
| 1615 | } | 1613 | } |
| 1616 | 1614 | ||
| 1617 | fn airFieldParentPtr(self: *Self, inst: Air.Inst.Index) !void { | 1615 | fn airFieldParentPtr(self: *Self, inst: Air.Inst.Index) !void { |
| 1618 | _ = self; | ||
| 1619 | _ = inst; | 1616 | _ = inst; |
| 1620 | return self.fail("TODO implement codegen airFieldParentPtr", .{}); | 1617 | return self.fail("TODO implement codegen airFieldParentPtr", .{}); |
| 1621 | } | 1618 | } |
src/arch/sparc64/CodeGen.zig-2| ... | @@ -2084,9 +2084,7 @@ fn airStructFieldVal(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -2084,9 +2084,7 @@ fn airStructFieldVal(self: *Self, inst: Air.Inst.Index) !void { |
| 2084 | } | 2084 | } |
| 2085 | 2085 | ||
| 2086 | fn airSwitch(self: *Self, inst: Air.Inst.Index) !void { | 2086 | fn airSwitch(self: *Self, inst: Air.Inst.Index) !void { |
| 2087 | _ = self; | ||
| 2088 | _ = inst; | 2087 | _ = inst; |
| 2089 | |||
| 2090 | return self.fail("TODO implement switch for {}", .{self.target.cpu.arch}); | 2088 | return self.fail("TODO implement switch for {}", .{self.target.cpu.arch}); |
| 2091 | } | 2089 | } |
| 2092 | 2090 |
src/arch/x86_64/CodeGen.zig-2| ... | @@ -1960,7 +1960,6 @@ fn airErrUnionPayloadPtrSet(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -1960,7 +1960,6 @@ fn airErrUnionPayloadPtrSet(self: *Self, inst: Air.Inst.Index) !void { |
| 1960 | } | 1960 | } |
| 1961 | 1961 | ||
| 1962 | fn airErrReturnTrace(self: *Self, inst: Air.Inst.Index) !void { | 1962 | fn airErrReturnTrace(self: *Self, inst: Air.Inst.Index) !void { |
| 1963 | _ = inst; | ||
| 1964 | const result: MCValue = if (self.liveness.isUnused(inst)) | 1963 | const result: MCValue = if (self.liveness.isUnused(inst)) |
| 1965 | .dead | 1964 | .dead |
| 1966 | else | 1965 | else |
| ... | @@ -6590,7 +6589,6 @@ fn airFloatToInt(self: *Self, inst: Air.Inst.Index) !void { | ... | @@ -6590,7 +6589,6 @@ fn airFloatToInt(self: *Self, inst: Air.Inst.Index) !void { |
| 6590 | fn airCmpxchg(self: *Self, inst: Air.Inst.Index) !void { | 6589 | fn airCmpxchg(self: *Self, inst: Air.Inst.Index) !void { |
| 6591 | const ty_pl = self.air.instructions.items(.data)[inst].ty_pl; | 6590 | const ty_pl = self.air.instructions.items(.data)[inst].ty_pl; |
| 6592 | const extra = self.air.extraData(Air.Block, ty_pl.payload); | 6591 | const extra = self.air.extraData(Air.Block, ty_pl.payload); |
| 6593 | _ = ty_pl; | ||
| 6594 | _ = extra; | 6592 | _ = extra; |
| 6595 | return self.fail("TODO implement x86 airCmpxchg", .{}); | 6593 | return self.fail("TODO implement x86 airCmpxchg", .{}); |
| 6596 | // return self.finishAir(inst, result, .{ extra.ptr, extra.expected_value, extra.new_value }); | 6594 | // return self.finishAir(inst, result, .{ extra.ptr, extra.expected_value, extra.new_value }); |
src/link/Plan9.zig-1| ... | @@ -622,7 +622,6 @@ pub fn updateDeclExports( | ... | @@ -622,7 +622,6 @@ pub fn updateDeclExports( |
| 622 | ) !void { | 622 | ) !void { |
| 623 | try self.seeDecl(decl_index); | 623 | try self.seeDecl(decl_index); |
| 624 | // we do all the things in flush | 624 | // we do all the things in flush |
| 625 | _ = self; | ||
| 626 | _ = module; | 625 | _ = module; |
| 627 | _ = exports; | 626 | _ = exports; |
| 628 | } | 627 | } |
src/print_air.zig-1| ... | @@ -324,7 +324,6 @@ const Writer = struct { | ... | @@ -324,7 +324,6 @@ const Writer = struct { |
| 324 | fn writeNoOp(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { | 324 | fn writeNoOp(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { |
| 325 | _ = w; | 325 | _ = w; |
| 326 | _ = inst; | 326 | _ = inst; |
| 327 | _ = s; | ||
| 328 | // no-op, no argument to write | 327 | // no-op, no argument to write |
| 329 | } | 328 | } |
| 330 | 329 |
src/translate_c/ast.zig+21-8| ... | @@ -1550,14 +1550,27 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex { | ... | @@ -1550,14 +1550,27 @@ fn renderNode(c: *Context, node: Node) Allocator.Error!NodeIndex { |
| 1550 | .main_token = try c.addToken(.identifier, "_"), | 1550 | .main_token = try c.addToken(.identifier, "_"), |
| 1551 | .data = undefined, | 1551 | .data = undefined, |
| 1552 | }); | 1552 | }); |
| 1553 | return c.addNode(.{ | 1553 | const main_token = try c.addToken(.equal, "="); |
| 1554 | .tag = .assign, | 1554 | if (payload.value.tag() == .identifier) { |
| 1555 | .main_token = try c.addToken(.equal, "="), | 1555 | // Render as `_ = @TypeOf(foo);` to avoid tripping "pointless discard" error. |
| 1556 | .data = .{ | 1556 | return c.addNode(.{ |
| 1557 | .lhs = lhs, | 1557 | .tag = .assign, |
| 1558 | .rhs = try renderNode(c, payload.value), | 1558 | .main_token = main_token, |
| 1559 | }, | 1559 | .data = .{ |
| 1560 | }); | 1560 | .lhs = lhs, |
| 1561 | .rhs = try renderBuiltinCall(c, "@TypeOf", &.{payload.value}), | ||
| 1562 | }, | ||
| 1563 | }); | ||
| 1564 | } else { | ||
| 1565 | return c.addNode(.{ | ||
| 1566 | .tag = .assign, | ||
| 1567 | .main_token = main_token, | ||
| 1568 | .data = .{ | ||
| 1569 | .lhs = lhs, | ||
| 1570 | .rhs = try renderNode(c, payload.value), | ||
| 1571 | }, | ||
| 1572 | }); | ||
| 1573 | } | ||
| 1561 | }, | 1574 | }, |
| 1562 | .@"while" => { | 1575 | .@"while" => { |
| 1563 | const payload = node.castTag(.@"while").?.data; | 1576 | const payload = node.castTag(.@"while").?.data; |
src/type.zig+18-7| ... | @@ -2715,8 +2715,12 @@ pub const Type = extern union { | ... | @@ -2715,8 +2715,12 @@ pub const Type = extern union { |
| 2715 | } | 2715 | } |
| 2716 | 2716 | ||
| 2717 | /// Returns 0 if the pointer is naturally aligned and the element type is 0-bit. | 2717 | /// Returns 0 if the pointer is naturally aligned and the element type is 0-bit. |
| 2718 | pub fn ptrAlignment(self: Type, target: Target) u32 { | 2718 | pub fn ptrAlignment(ty: Type, target: Target) u32 { |
| 2719 | switch (self.tag()) { | 2719 | return ptrAlignmentAdvanced(ty, target, null) catch unreachable; |
| 2720 | } | ||
| 2721 | |||
| 2722 | pub fn ptrAlignmentAdvanced(ty: Type, target: Target, sema_kit: ?Module.WipAnalysis) !u32 { | ||
| 2723 | switch (ty.tag()) { | ||
| 2720 | .single_const_pointer, | 2724 | .single_const_pointer, |
| 2721 | .single_mut_pointer, | 2725 | .single_mut_pointer, |
| 2722 | .many_const_pointer, | 2726 | .many_const_pointer, |
| ... | @@ -2728,8 +2732,12 @@ pub const Type = extern union { | ... | @@ -2728,8 +2732,12 @@ pub const Type = extern union { |
| 2728 | .optional_single_const_pointer, | 2732 | .optional_single_const_pointer, |
| 2729 | .optional_single_mut_pointer, | 2733 | .optional_single_mut_pointer, |
| 2730 | => { | 2734 | => { |
| 2731 | const child_type = self.cast(Payload.ElemType).?.data; | 2735 | const child_type = ty.cast(Payload.ElemType).?.data; |
| 2732 | return child_type.abiAlignment(target); | 2736 | if (sema_kit) |sk| { |
| 2737 | const res = try child_type.abiAlignmentAdvanced(target, .{ .sema_kit = sk }); | ||
| 2738 | return res.scalar; | ||
| 2739 | } | ||
| 2740 | return (child_type.abiAlignmentAdvanced(target, .eager) catch unreachable).scalar; | ||
| 2733 | }, | 2741 | }, |
| 2734 | 2742 | ||
| 2735 | .manyptr_u8, | 2743 | .manyptr_u8, |
| ... | @@ -2740,14 +2748,17 @@ pub const Type = extern union { | ... | @@ -2740,14 +2748,17 @@ pub const Type = extern union { |
| 2740 | => return 1, | 2748 | => return 1, |
| 2741 | 2749 | ||
| 2742 | .pointer => { | 2750 | .pointer => { |
| 2743 | const ptr_info = self.castTag(.pointer).?.data; | 2751 | const ptr_info = ty.castTag(.pointer).?.data; |
| 2744 | if (ptr_info.@"align" != 0) { | 2752 | if (ptr_info.@"align" != 0) { |
| 2745 | return ptr_info.@"align"; | 2753 | return ptr_info.@"align"; |
| 2754 | } else if (sema_kit) |sk| { | ||
| 2755 | const res = try ptr_info.pointee_type.abiAlignmentAdvanced(target, .{ .sema_kit = sk }); | ||
| 2756 | return res.scalar; | ||
| 2746 | } else { | 2757 | } else { |
| 2747 | return ptr_info.pointee_type.abiAlignment(target); | 2758 | return (ptr_info.pointee_type.abiAlignmentAdvanced(target, .eager) catch unreachable).scalar; |
| 2748 | } | 2759 | } |
| 2749 | }, | 2760 | }, |
| 2750 | .optional => return self.castTag(.optional).?.data.ptrAlignment(target), | 2761 | .optional => return ty.castTag(.optional).?.data.ptrAlignmentAdvanced(target, sema_kit), |
| 2751 | 2762 | ||
| 2752 | else => unreachable, | 2763 | else => unreachable, |
| 2753 | } | 2764 | } |
test/behavior/bugs/11165.zig-2| ... | @@ -14,7 +14,6 @@ test "bytes" { | ... | @@ -14,7 +14,6 @@ test "bytes" { |
| 14 | .a = undefined, | 14 | .a = undefined, |
| 15 | .c = "12345".*, // this caused problems | 15 | .c = "12345".*, // this caused problems |
| 16 | }; | 16 | }; |
| 17 | _ = s_1; | ||
| 18 | 17 | ||
| 19 | var u_2 = U{ .s = s_1 }; | 18 | var u_2 = U{ .s = s_1 }; |
| 20 | _ = u_2; | 19 | _ = u_2; |
| ... | @@ -35,7 +34,6 @@ test "aggregate" { | ... | @@ -35,7 +34,6 @@ test "aggregate" { |
| 35 | .a = undefined, | 34 | .a = undefined, |
| 36 | .c = c, // this caused problems | 35 | .c = c, // this caused problems |
| 37 | }; | 36 | }; |
| 38 | _ = s_1; | ||
| 39 | 37 | ||
| 40 | var u_2 = U{ .s = s_1 }; | 38 | var u_2 = U{ .s = s_1 }; |
| 41 | _ = u_2; | 39 | _ = u_2; |
test/behavior/type.zig-2| ... | @@ -486,7 +486,6 @@ test "Type.Union from Type.Enum" { | ... | @@ -486,7 +486,6 @@ test "Type.Union from Type.Enum" { |
| 486 | .decls = &.{}, | 486 | .decls = &.{}, |
| 487 | }, | 487 | }, |
| 488 | }); | 488 | }); |
| 489 | _ = T; | ||
| 490 | _ = @typeInfo(T).Union; | 489 | _ = @typeInfo(T).Union; |
| 491 | } | 490 | } |
| 492 | 491 | ||
| ... | @@ -505,7 +504,6 @@ test "Type.Union from regular enum" { | ... | @@ -505,7 +504,6 @@ test "Type.Union from regular enum" { |
| 505 | .decls = &.{}, | 504 | .decls = &.{}, |
| 506 | }, | 505 | }, |
| 507 | }); | 506 | }); |
| 508 | _ = T; | ||
| 509 | _ = @typeInfo(T).Union; | 507 | _ = @typeInfo(T).Union; |
| 510 | } | 508 | } |
| 511 | 509 |
test/behavior/type_info.zig+2-6| ... | @@ -425,12 +425,8 @@ fn generic2(comptime T: type, param: T, param2: u8) void { | ... | @@ -425,12 +425,8 @@ fn generic2(comptime T: type, param: T, param2: u8) void { |
| 425 | _ = param; | 425 | _ = param; |
| 426 | _ = param2; | 426 | _ = param2; |
| 427 | } | 427 | } |
| 428 | fn generic3(param: anytype) @TypeOf(param) { | 428 | fn generic3(param: anytype) @TypeOf(param) {} |
| 429 | _ = param; | 429 | fn generic4(comptime param: anytype) @TypeOf(param) {} |
| 430 | } | ||
| 431 | fn generic4(comptime param: anytype) @TypeOf(param) { | ||
| 432 | _ = param; | ||
| 433 | } | ||
| 434 | 430 | ||
| 435 | test "typeInfo with comptime parameter in struct fn def" { | 431 | test "typeInfo with comptime parameter in struct fn def" { |
| 436 | const S = struct { | 432 | const S = struct { |
test/cases/compile_errors/non-comptime-parameter-used-as-array-size.zig-1| ... | @@ -6,7 +6,6 @@ export fn entry() void { | ... | @@ -6,7 +6,6 @@ export fn entry() void { |
| 6 | } | 6 | } |
| 7 | 7 | ||
| 8 | fn makeLlamas(count: usize) [count]u8 { | 8 | fn makeLlamas(count: usize) [count]u8 { |
| 9 | _ = count; | ||
| 10 | } | 9 | } |
| 11 | 10 | ||
| 12 | // error | 11 | // error |
test/cases/compile_errors/pointless discard.zig	 created+12| ... | @@ -0,0 +1,12 @@ | ||
| 1 | export fn foo() void { | ||
| 2 | var x: i32 = 1234; | ||
| 3 | x += 1; | ||
| 4 | _ = x; | ||
| 5 | } | ||
| 6 | |||
| 7 | // error | ||
| 8 | // backend=stage2 | ||
| 9 | // target=native | ||
| 10 | // | ||
| 11 | // :4:9: error: pointless discard of local variable | ||
| 12 | // :3:5: note: used here | ||
test/cases/type_of.0.zig-1| ... | @@ -1,6 +1,5 @@ | ... | @@ -1,6 +1,5 @@ |
| 1 | pub fn main() void { | 1 | pub fn main() void { |
| 2 | var x: usize = 0; | 2 | var x: usize = 0; |
| 3 | _ = x; | ||
| 4 | const z = @TypeOf(x, @as(u128, 5)); | 3 | const z = @TypeOf(x, @as(u128, 5)); |
| 5 | assert(z == u128); | 4 | assert(z == u128); |
| 6 | } | 5 | } |
test/translate_c.zig+57-57| ... | @@ -116,10 +116,10 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -116,10 +116,10 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 116 | \\pub export fn foo() void { | 116 | \\pub export fn foo() void { |
| 117 | \\ while (true) if (true) { | 117 | \\ while (true) if (true) { |
| 118 | \\ var a: c_int = 1; | 118 | \\ var a: c_int = 1; |
| 119 | \\ _ = a; | 119 | \\ _ = @TypeOf(a); |
| 120 | \\ } else { | 120 | \\ } else { |
| 121 | \\ var b: c_int = 2; | 121 | \\ var b: c_int = 2; |
| 122 | \\ _ = b; | 122 | \\ _ = @TypeOf(b); |
| 123 | \\ }; | 123 | \\ }; |
| 124 | \\ if (true) if (true) {}; | 124 | \\ if (true) if (true) {}; |
| 125 | \\} | 125 | \\} |
| ... | @@ -192,7 +192,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -192,7 +192,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 192 | \\ .B = 0, | 192 | \\ .B = 0, |
| 193 | \\ .C = 0, | 193 | \\ .C = 0, |
| 194 | \\ }; | 194 | \\ }; |
| 195 | \\ _ = a; | 195 | \\ _ = @TypeOf(a); |
| 196 | \\ { | 196 | \\ { |
| 197 | \\ const struct_Foo_1 = extern struct { | 197 | \\ const struct_Foo_1 = extern struct { |
| 198 | \\ A: c_int, | 198 | \\ A: c_int, |
| ... | @@ -204,7 +204,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -204,7 +204,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 204 | \\ .B = 0, | 204 | \\ .B = 0, |
| 205 | \\ .C = 0, | 205 | \\ .C = 0, |
| 206 | \\ }; | 206 | \\ }; |
| 207 | \\ _ = a_2; | 207 | \\ _ = @TypeOf(a_2); |
| 208 | \\ } | 208 | \\ } |
| 209 | \\} | 209 | \\} |
| 210 | }); | 210 | }); |
| ... | @@ -233,24 +233,24 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -233,24 +233,24 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 233 | \\ B: c_int, | 233 | \\ B: c_int, |
| 234 | \\ C: c_int, | 234 | \\ C: c_int, |
| 235 | \\ }; | 235 | \\ }; |
| 236 | \\ _ = union_unnamed_1; | 236 | \\ _ = @TypeOf(union_unnamed_1); |
| 237 | \\ const Foo = union_unnamed_1; | 237 | \\ const Foo = union_unnamed_1; |
| 238 | \\ var a: Foo = Foo{ | 238 | \\ var a: Foo = Foo{ |
| 239 | \\ .A = @as(c_int, 0), | 239 | \\ .A = @as(c_int, 0), |
| 240 | \\ }; | 240 | \\ }; |
| 241 | \\ _ = a; | 241 | \\ _ = @TypeOf(a); |
| 242 | \\ { | 242 | \\ { |
| 243 | \\ const union_unnamed_2 = extern union { | 243 | \\ const union_unnamed_2 = extern union { |
| 244 | \\ A: c_int, | 244 | \\ A: c_int, |
| 245 | \\ B: c_int, | 245 | \\ B: c_int, |
| 246 | \\ C: c_int, | 246 | \\ C: c_int, |
| 247 | \\ }; | 247 | \\ }; |
| 248 | \\ _ = union_unnamed_2; | 248 | \\ _ = @TypeOf(union_unnamed_2); |
| 249 | \\ const Foo_1 = union_unnamed_2; | 249 | \\ const Foo_1 = union_unnamed_2; |
| 250 | \\ var a_2: Foo_1 = Foo_1{ | 250 | \\ var a_2: Foo_1 = Foo_1{ |
| 251 | \\ .A = @as(c_int, 0), | 251 | \\ .A = @as(c_int, 0), |
| 252 | \\ }; | 252 | \\ }; |
| 253 | \\ _ = a_2; | 253 | \\ _ = @TypeOf(a_2); |
| 254 | \\ } | 254 | \\ } |
| 255 | \\} | 255 | \\} |
| 256 | }); | 256 | }); |
| ... | @@ -318,7 +318,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -318,7 +318,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 318 | \\ const bar_1 = struct { | 318 | \\ const bar_1 = struct { |
| 319 | \\ threadlocal var static: c_int = 2; | 319 | \\ threadlocal var static: c_int = 2; |
| 320 | \\ }; | 320 | \\ }; |
| 321 | \\ _ = bar_1; | 321 | \\ _ = @TypeOf(bar_1); |
| 322 | \\ return 0; | 322 | \\ return 0; |
| 323 | \\} | 323 | \\} |
| 324 | }); | 324 | }); |
| ... | @@ -337,7 +337,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -337,7 +337,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 337 | \\} | 337 | \\} |
| 338 | \\pub export fn bar() c_int { | 338 | \\pub export fn bar() c_int { |
| 339 | \\ var a: c_int = 2; | 339 | \\ var a: c_int = 2; |
| 340 | \\ _ = a; | 340 | \\ _ = @TypeOf(a); |
| 341 | \\ return 0; | 341 | \\ return 0; |
| 342 | \\} | 342 | \\} |
| 343 | \\pub export fn baz() c_int { | 343 | \\pub export fn baz() c_int { |
| ... | @@ -352,7 +352,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -352,7 +352,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 352 | , &[_][]const u8{ | 352 | , &[_][]const u8{ |
| 353 | \\pub export fn main() void { | 353 | \\pub export fn main() void { |
| 354 | \\ var a: c_int = @bitCast(c_int, @truncate(c_uint, @alignOf(c_int))); | 354 | \\ var a: c_int = @bitCast(c_int, @truncate(c_uint, @alignOf(c_int))); |
| 355 | \\ _ = a; | 355 | \\ _ = @TypeOf(a); |
| 356 | \\} | 356 | \\} |
| 357 | }); | 357 | }); |
| 358 | 358 | ||
| ... | @@ -500,7 +500,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -500,7 +500,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 500 | \\#define bar(x) (&x, +3, 4 == 4, 5 * 6, baz(1, 2), 2 % 2, baz(1,2)) | 500 | \\#define bar(x) (&x, +3, 4 == 4, 5 * 6, baz(1, 2), 2 % 2, baz(1,2)) |
| 501 | , &[_][]const u8{ | 501 | , &[_][]const u8{ |
| 502 | \\pub const foo = blk: { | 502 | \\pub const foo = blk: { |
| 503 | \\ _ = foo; | 503 | \\ _ = @TypeOf(foo); |
| 504 | \\ break :blk bar; | 504 | \\ break :blk bar; |
| 505 | \\}; | 505 | \\}; |
| 506 | , | 506 | , |
| ... | @@ -724,7 +724,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -724,7 +724,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 724 | \\pub export fn function(arg_opaque_1: ?*struct_opaque) void { | 724 | \\pub export fn function(arg_opaque_1: ?*struct_opaque) void { |
| 725 | \\ var opaque_1 = arg_opaque_1; | 725 | \\ var opaque_1 = arg_opaque_1; |
| 726 | \\ var cast: ?*struct_opaque_2 = @ptrCast(?*struct_opaque_2, opaque_1); | 726 | \\ var cast: ?*struct_opaque_2 = @ptrCast(?*struct_opaque_2, opaque_1); |
| 727 | \\ _ = cast; | 727 | \\ _ = @TypeOf(cast); |
| 728 | \\} | 728 | \\} |
| 729 | }); | 729 | }); |
| 730 | 730 | ||
| ... | @@ -761,7 +761,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -761,7 +761,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 761 | \\pub export fn my_fn() align(128) void {} | 761 | \\pub export fn my_fn() align(128) void {} |
| 762 | \\pub export fn other_fn() void { | 762 | \\pub export fn other_fn() void { |
| 763 | \\ var ARR: [16]u8 align(16) = undefined; | 763 | \\ var ARR: [16]u8 align(16) = undefined; |
| 764 | \\ _ = ARR; | 764 | \\ _ = @TypeOf(ARR); |
| 765 | \\} | 765 | \\} |
| 766 | }); | 766 | }); |
| 767 | } | 767 | } |
| ... | @@ -798,17 +798,17 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -798,17 +798,17 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 798 | , &[_][]const u8{ | 798 | , &[_][]const u8{ |
| 799 | \\pub export fn foo() void { | 799 | \\pub export fn foo() void { |
| 800 | \\ var a: c_int = undefined; | 800 | \\ var a: c_int = undefined; |
| 801 | \\ _ = a; | 801 | \\ _ = @TypeOf(a); |
| 802 | \\ var b: u8 = 123; | 802 | \\ var b: u8 = 123; |
| 803 | \\ _ = b; | 803 | \\ _ = @TypeOf(b); |
| 804 | \\ const c: c_int = undefined; | 804 | \\ const c: c_int = undefined; |
| 805 | \\ _ = c; | 805 | \\ _ = @TypeOf(c); |
| 806 | \\ const d: c_uint = @bitCast(c_uint, @as(c_int, 440)); | 806 | \\ const d: c_uint = @bitCast(c_uint, @as(c_int, 440)); |
| 807 | \\ _ = d; | 807 | \\ _ = @TypeOf(d); |
| 808 | \\ var e: c_int = 10; | 808 | \\ var e: c_int = 10; |
| 809 | \\ _ = e; | 809 | \\ _ = @TypeOf(e); |
| 810 | \\ var f: c_uint = 10; | 810 | \\ var f: c_uint = 10; |
| 811 | \\ _ = f; | 811 | \\ _ = @TypeOf(f); |
| 812 | \\} | 812 | \\} |
| 813 | }); | 813 | }); |
| 814 | 814 | ||
| ... | @@ -867,7 +867,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -867,7 +867,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 867 | \\ const v2 = struct { | 867 | \\ const v2 = struct { |
| 868 | \\ const static: [5:0]u8 = "2.2.2".*; | 868 | \\ const static: [5:0]u8 = "2.2.2".*; |
| 869 | \\ }; | 869 | \\ }; |
| 870 | \\ _ = v2; | 870 | \\ _ = @TypeOf(v2); |
| 871 | \\} | 871 | \\} |
| 872 | }); | 872 | }); |
| 873 | 873 | ||
| ... | @@ -911,7 +911,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -911,7 +911,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 911 | \\pub export fn bar() void { | 911 | \\pub export fn bar() void { |
| 912 | \\ var func_ptr: ?*anyopaque = @ptrCast(?*anyopaque, foo); | 912 | \\ var func_ptr: ?*anyopaque = @ptrCast(?*anyopaque, foo); |
| 913 | \\ var typed_func_ptr: ?*const fn () callconv(.C) void = @intToPtr(?*const fn () callconv(.C) void, @intCast(c_ulong, @ptrToInt(func_ptr))); | 913 | \\ var typed_func_ptr: ?*const fn () callconv(.C) void = @intToPtr(?*const fn () callconv(.C) void, @intCast(c_ulong, @ptrToInt(func_ptr))); |
| 914 | \\ _ = typed_func_ptr; | 914 | \\ _ = @TypeOf(typed_func_ptr); |
| 915 | \\} | 915 | \\} |
| 916 | }); | 916 | }); |
| 917 | } | 917 | } |
| ... | @@ -1353,7 +1353,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -1353,7 +1353,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 1353 | , &[_][]const u8{ | 1353 | , &[_][]const u8{ |
| 1354 | \\pub export fn foo() void { | 1354 | \\pub export fn foo() void { |
| 1355 | \\ var a: c_int = undefined; | 1355 | \\ var a: c_int = undefined; |
| 1356 | \\ _ = a; | 1356 | \\ _ = @TypeOf(a); |
| 1357 | \\} | 1357 | \\} |
| 1358 | }); | 1358 | }); |
| 1359 | 1359 | ||
| ... | @@ -1524,23 +1524,23 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -1524,23 +1524,23 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 1524 | \\ var p: ?*anyopaque = undefined; | 1524 | \\ var p: ?*anyopaque = undefined; |
| 1525 | \\ { | 1525 | \\ { |
| 1526 | \\ var to_char: [*c]u8 = @ptrCast([*c]u8, @alignCast(@import("std").meta.alignment([*c]u8), p)); | 1526 | \\ var to_char: [*c]u8 = @ptrCast([*c]u8, @alignCast(@import("std").meta.alignment([*c]u8), p)); |
| 1527 | \\ _ = to_char; | 1527 | \\ _ = @TypeOf(to_char); |
| 1528 | \\ var to_short: [*c]c_short = @ptrCast([*c]c_short, @alignCast(@import("std").meta.alignment([*c]c_short), p)); | 1528 | \\ var to_short: [*c]c_short = @ptrCast([*c]c_short, @alignCast(@import("std").meta.alignment([*c]c_short), p)); |
| 1529 | \\ _ = to_short; | 1529 | \\ _ = @TypeOf(to_short); |
| 1530 | \\ var to_int: [*c]c_int = @ptrCast([*c]c_int, @alignCast(@import("std").meta.alignment([*c]c_int), p)); | 1530 | \\ var to_int: [*c]c_int = @ptrCast([*c]c_int, @alignCast(@import("std").meta.alignment([*c]c_int), p)); |
| 1531 | \\ _ = to_int; | 1531 | \\ _ = @TypeOf(to_int); |
| 1532 | \\ var to_longlong: [*c]c_longlong = @ptrCast([*c]c_longlong, @alignCast(@import("std").meta.alignment([*c]c_longlong), p)); | 1532 | \\ var to_longlong: [*c]c_longlong = @ptrCast([*c]c_longlong, @alignCast(@import("std").meta.alignment([*c]c_longlong), p)); |
| 1533 | \\ _ = to_longlong; | 1533 | \\ _ = @TypeOf(to_longlong); |
| 1534 | \\ } | 1534 | \\ } |
| 1535 | \\ { | 1535 | \\ { |
| 1536 | \\ var to_char: [*c]u8 = @ptrCast([*c]u8, @alignCast(@import("std").meta.alignment([*c]u8), p)); | 1536 | \\ var to_char: [*c]u8 = @ptrCast([*c]u8, @alignCast(@import("std").meta.alignment([*c]u8), p)); |
| 1537 | \\ _ = to_char; | 1537 | \\ _ = @TypeOf(to_char); |
| 1538 | \\ var to_short: [*c]c_short = @ptrCast([*c]c_short, @alignCast(@import("std").meta.alignment([*c]c_short), p)); | 1538 | \\ var to_short: [*c]c_short = @ptrCast([*c]c_short, @alignCast(@import("std").meta.alignment([*c]c_short), p)); |
| 1539 | \\ _ = to_short; | 1539 | \\ _ = @TypeOf(to_short); |
| 1540 | \\ var to_int: [*c]c_int = @ptrCast([*c]c_int, @alignCast(@import("std").meta.alignment([*c]c_int), p)); | 1540 | \\ var to_int: [*c]c_int = @ptrCast([*c]c_int, @alignCast(@import("std").meta.alignment([*c]c_int), p)); |
| 1541 | \\ _ = to_int; | 1541 | \\ _ = @TypeOf(to_int); |
| 1542 | \\ var to_longlong: [*c]c_longlong = @ptrCast([*c]c_longlong, @alignCast(@import("std").meta.alignment([*c]c_longlong), p)); | 1542 | \\ var to_longlong: [*c]c_longlong = @ptrCast([*c]c_longlong, @alignCast(@import("std").meta.alignment([*c]c_longlong), p)); |
| 1543 | \\ _ = to_longlong; | 1543 | \\ _ = @TypeOf(to_longlong); |
| 1544 | \\ } | 1544 | \\ } |
| 1545 | \\} | 1545 | \\} |
| 1546 | }); | 1546 | }); |
| ... | @@ -1786,11 +1786,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -1786,11 +1786,11 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 1786 | \\ var arr: [10]u8 = [1]u8{ | 1786 | \\ var arr: [10]u8 = [1]u8{ |
| 1787 | \\ 1, | 1787 | \\ 1, |
| 1788 | \\ } ++ [1]u8{0} ** 9; | 1788 | \\ } ++ [1]u8{0} ** 9; |
| 1789 | \\ _ = arr; | 1789 | \\ _ = @TypeOf(arr); |
| 1790 | \\ var arr1: [10][*c]u8 = [1][*c]u8{ | 1790 | \\ var arr1: [10][*c]u8 = [1][*c]u8{ |
| 1791 | \\ null, | 1791 | \\ null, |
| 1792 | \\ } ++ [1][*c]u8{null} ** 9; | 1792 | \\ } ++ [1][*c]u8{null} ** 9; |
| 1793 | \\ _ = arr1; | 1793 | \\ _ = @TypeOf(arr1); |
| 1794 | \\} | 1794 | \\} |
| 1795 | }); | 1795 | }); |
| 1796 | 1796 | ||
| ... | @@ -2038,16 +2038,16 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -2038,16 +2038,16 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2038 | \\pub var c: c_int = 4; | 2038 | \\pub var c: c_int = 4; |
| 2039 | \\pub export fn foo(arg_c_1: u8) void { | 2039 | \\pub export fn foo(arg_c_1: u8) void { |
| 2040 | \\ var c_1 = arg_c_1; | 2040 | \\ var c_1 = arg_c_1; |
| 2041 | \\ _ = c_1; | 2041 | \\ _ = @TypeOf(c_1); |
| 2042 | \\ var a_2: c_int = undefined; | 2042 | \\ var a_2: c_int = undefined; |
| 2043 | \\ var b_3: u8 = 123; | 2043 | \\ var b_3: u8 = 123; |
| 2044 | \\ b_3 = @bitCast(u8, @truncate(i8, a_2)); | 2044 | \\ b_3 = @bitCast(u8, @truncate(i8, a_2)); |
| 2045 | \\ { | 2045 | \\ { |
| 2046 | \\ var d: c_int = 5; | 2046 | \\ var d: c_int = 5; |
| 2047 | \\ _ = d; | 2047 | \\ _ = @TypeOf(d); |
| 2048 | \\ } | 2048 | \\ } |
| 2049 | \\ var d: c_uint = @bitCast(c_uint, @as(c_int, 440)); | 2049 | \\ var d: c_uint = @bitCast(c_uint, @as(c_int, 440)); |
| 2050 | \\ _ = d; | 2050 | \\ _ = @TypeOf(d); |
| 2051 | \\} | 2051 | \\} |
| 2052 | }); | 2052 | }); |
| 2053 | 2053 | ||
| ... | @@ -2146,7 +2146,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -2146,7 +2146,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2146 | \\ { | 2146 | \\ { |
| 2147 | \\ var i: c_int = 2; | 2147 | \\ var i: c_int = 2; |
| 2148 | \\ var b: c_int = 4; | 2148 | \\ var b: c_int = 4; |
| 2149 | \\ _ = b; | 2149 | \\ _ = @TypeOf(b); |
| 2150 | \\ while ((i + @as(c_int, 2)) != 0) : (i = 2) { | 2150 | \\ while ((i + @as(c_int, 2)) != 0) : (i = 2) { |
| 2151 | \\ var a: c_int = 2; | 2151 | \\ var a: c_int = 2; |
| 2152 | \\ _ = blk: { | 2152 | \\ _ = blk: { |
| ... | @@ -2159,7 +2159,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -2159,7 +2159,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2159 | \\ } | 2159 | \\ } |
| 2160 | \\ } | 2160 | \\ } |
| 2161 | \\ var i: u8 = 2; | 2161 | \\ var i: u8 = 2; |
| 2162 | \\ _ = i; | 2162 | \\ _ = @TypeOf(i); |
| 2163 | \\} | 2163 | \\} |
| 2164 | }); | 2164 | }); |
| 2165 | 2165 | ||
| ... | @@ -2396,27 +2396,27 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -2396,27 +2396,27 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2396 | , &[_][]const u8{ | 2396 | , &[_][]const u8{ |
| 2397 | \\pub export fn escapes() [*c]const u8 { | 2397 | \\pub export fn escapes() [*c]const u8 { |
| 2398 | \\ var a: u8 = '\''; | 2398 | \\ var a: u8 = '\''; |
| 2399 | \\ _ = a; | 2399 | \\ _ = @TypeOf(a); |
| 2400 | \\ var b: u8 = '\\'; | 2400 | \\ var b: u8 = '\\'; |
| 2401 | \\ _ = b; | 2401 | \\ _ = @TypeOf(b); |
| 2402 | \\ var c: u8 = '\x07'; | 2402 | \\ var c: u8 = '\x07'; |
| 2403 | \\ _ = c; | 2403 | \\ _ = @TypeOf(c); |
| 2404 | \\ var d: u8 = '\x08'; | 2404 | \\ var d: u8 = '\x08'; |
| 2405 | \\ _ = d; | 2405 | \\ _ = @TypeOf(d); |
| 2406 | \\ var e: u8 = '\x0c'; | 2406 | \\ var e: u8 = '\x0c'; |
| 2407 | \\ _ = e; | 2407 | \\ _ = @TypeOf(e); |
| 2408 | \\ var f: u8 = '\n'; | 2408 | \\ var f: u8 = '\n'; |
| 2409 | \\ _ = f; | 2409 | \\ _ = @TypeOf(f); |
| 2410 | \\ var g: u8 = '\r'; | 2410 | \\ var g: u8 = '\r'; |
| 2411 | \\ _ = g; | 2411 | \\ _ = @TypeOf(g); |
| 2412 | \\ var h: u8 = '\t'; | 2412 | \\ var h: u8 = '\t'; |
| 2413 | \\ _ = h; | 2413 | \\ _ = @TypeOf(h); |
| 2414 | \\ var i: u8 = '\x0b'; | 2414 | \\ var i: u8 = '\x0b'; |
| 2415 | \\ _ = i; | 2415 | \\ _ = @TypeOf(i); |
| 2416 | \\ var j: u8 = '\x00'; | 2416 | \\ var j: u8 = '\x00'; |
| 2417 | \\ _ = j; | 2417 | \\ _ = @TypeOf(j); |
| 2418 | \\ var k: u8 = '"'; | 2418 | \\ var k: u8 = '"'; |
| 2419 | \\ _ = k; | 2419 | \\ _ = @TypeOf(k); |
| 2420 | \\ return "'\\\x07\x08\x0c\n\r\t\x0b\x00\""; | 2420 | \\ return "'\\\x07\x08\x0c\n\r\t\x0b\x00\""; |
| 2421 | \\} | 2421 | \\} |
| 2422 | }); | 2422 | }); |
| ... | @@ -2612,7 +2612,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -2612,7 +2612,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2612 | \\pub export fn foo() c_int { | 2612 | \\pub export fn foo() c_int { |
| 2613 | \\ return blk: { | 2613 | \\ return blk: { |
| 2614 | \\ var a: c_int = 1; | 2614 | \\ var a: c_int = 1; |
| 2615 | \\ _ = a; | 2615 | \\ _ = @TypeOf(a); |
| 2616 | \\ break :blk a; | 2616 | \\ break :blk a; |
| 2617 | \\ }; | 2617 | \\ }; |
| 2618 | \\} | 2618 | \\} |
| ... | @@ -2716,7 +2716,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -2716,7 +2716,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2716 | \\int bar(void) { return 0; } | 2716 | \\int bar(void) { return 0; } |
| 2717 | , &[_][]const u8{ | 2717 | , &[_][]const u8{ |
| 2718 | \\pub inline fn CALL(arg: anytype) @TypeOf(bar()) { | 2718 | \\pub inline fn CALL(arg: anytype) @TypeOf(bar()) { |
| 2719 | \\ _ = arg; | 2719 | \\ _ = @TypeOf(arg); |
| 2720 | \\ return bar(); | 2720 | \\ return bar(); |
| 2721 | \\} | 2721 | \\} |
| 2722 | }); | 2722 | }); |
| ... | @@ -2775,14 +2775,14 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -2775,14 +2775,14 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 2775 | \\pub export fn foo() void { | 2775 | \\pub export fn foo() void { |
| 2776 | \\ if (true) { | 2776 | \\ if (true) { |
| 2777 | \\ var a: c_int = 2; | 2777 | \\ var a: c_int = 2; |
| 2778 | \\ _ = a; | 2778 | \\ _ = @TypeOf(a); |
| 2779 | \\ } | 2779 | \\ } |
| 2780 | \\ if ((blk: { | 2780 | \\ if ((blk: { |
| 2781 | \\ _ = @as(c_int, 2); | 2781 | \\ _ = @as(c_int, 2); |
| 2782 | \\ break :blk @as(c_int, 5); | 2782 | \\ break :blk @as(c_int, 5); |
| 2783 | \\ }) != 0) { | 2783 | \\ }) != 0) { |
| 2784 | \\ var a: c_int = 2; | 2784 | \\ var a: c_int = 2; |
| 2785 | \\ _ = a; | 2785 | \\ _ = @TypeOf(a); |
| 2786 | \\ } | 2786 | \\ } |
| 2787 | \\} | 2787 | \\} |
| 2788 | }); | 2788 | }); |
| ... | @@ -3285,7 +3285,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -3285,7 +3285,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 3285 | \\#define a 2 | 3285 | \\#define a 2 |
| 3286 | , &[_][]const u8{ | 3286 | , &[_][]const u8{ |
| 3287 | \\pub inline fn FOO(bar: anytype) @TypeOf(baz(@import("std").zig.c_translation.cast(?*anyopaque, baz))) { | 3287 | \\pub inline fn FOO(bar: anytype) @TypeOf(baz(@import("std").zig.c_translation.cast(?*anyopaque, baz))) { |
| 3288 | \\ _ = bar; | 3288 | \\ _ = @TypeOf(bar); |
| 3289 | \\ return baz(@import("std").zig.c_translation.cast(?*anyopaque, baz)); | 3289 | \\ return baz(@import("std").zig.c_translation.cast(?*anyopaque, baz)); |
| 3290 | \\} | 3290 | \\} |
| 3291 | , | 3291 | , |
| ... | @@ -3425,7 +3425,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -3425,7 +3425,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 3425 | , &[_][]const u8{ | 3425 | , &[_][]const u8{ |
| 3426 | \\pub export fn foo(arg_a: [*c]c_int) void { | 3426 | \\pub export fn foo(arg_a: [*c]c_int) void { |
| 3427 | \\ var a = arg_a; | 3427 | \\ var a = arg_a; |
| 3428 | \\ _ = a; | 3428 | \\ _ = @TypeOf(a); |
| 3429 | \\} | 3429 | \\} |
| 3430 | \\pub export fn bar(arg_a: [*c]const c_int) void { | 3430 | \\pub export fn bar(arg_a: [*c]const c_int) void { |
| 3431 | \\ var a = arg_a; | 3431 | \\ var a = arg_a; |
| ... | @@ -3785,12 +3785,12 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -3785,12 +3785,12 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 3785 | \\pub export fn bar(arg_x: c_int, arg_y: c_int) c_int { | 3785 | \\pub export fn bar(arg_x: c_int, arg_y: c_int) c_int { |
| 3786 | \\ var x = arg_x; | 3786 | \\ var x = arg_x; |
| 3787 | \\ var y = arg_y; | 3787 | \\ var y = arg_y; |
| 3788 | \\ _ = y; | 3788 | \\ _ = @TypeOf(y); |
| 3789 | \\ return x; | 3789 | \\ return x; |
| 3790 | \\} | 3790 | \\} |
| 3791 | , | 3791 | , |
| 3792 | \\pub inline fn FOO(A: anytype, B: anytype) @TypeOf(A) { | 3792 | \\pub inline fn FOO(A: anytype, B: anytype) @TypeOf(A) { |
| 3793 | \\ _ = B; | 3793 | \\ _ = @TypeOf(B); |
| 3794 | \\ return A; | 3794 | \\ return A; |
| 3795 | \\} | 3795 | \\} |
| 3796 | }); | 3796 | }); |