| author | |
| committer | |
| log | 697c4ffd41cb99efbcf2e2c5393dd07533552881 |
| tree | 8095d46783869770edf8dc57d3c729381bacb99c |
| parent | c7fd414dab3c69819c6528e8dcbb9de8ab17cdf9 |
| parent | cf6fb89ced7d0f03b511dba19f02af4a87a70b62 |
| signature |
closes #36213 files changed, 20 insertions(+), 8 deletions(-)
lib/std/zig/tokenizer.zig+10| ... | @@ -1625,6 +1625,16 @@ test "tokenizer - UTF-8 BOM is recognized and skipped" { | ... | @@ -1625,6 +1625,16 @@ test "tokenizer - UTF-8 BOM is recognized and skipped" { |
| 1625 | }); | 1625 | }); |
| 1626 | } | 1626 | } |
| 1627 | 1627 | ||
| 1628 | test "correctly parse pointer assignment" { | ||
| 1629 | testTokenize("b.*=3;\n", [_]Token.Id{ | ||
| 1630 | Token.Id.Identifier, | ||
| 1631 | Token.Id.PeriodAsterisk, | ||
| 1632 | Token.Id.Equal, | ||
| 1633 | Token.Id.IntegerLiteral, | ||
| 1634 | Token.Id.Semicolon, | ||
| 1635 | }); | ||
| 1636 | } | ||
| 1637 | |||
| 1628 | fn testTokenize(source: []const u8, expected_tokens: []const Token.Id) void { | 1638 | fn testTokenize(source: []const u8, expected_tokens: []const Token.Id) void { |
| 1629 | var tokenizer = Tokenizer.init(source); | 1639 | var tokenizer = Tokenizer.init(source); |
| 1630 | for (expected_tokens) |expected_token_id| { | 1640 | for (expected_tokens) |expected_token_id| { |
src/codegen.cpp+4-8| ... | @@ -7050,16 +7050,12 @@ check: switch (const_val->special) { | ... | @@ -7050,16 +7050,12 @@ check: switch (const_val->special) { |
| 7050 | case ZigTypeIdEnum: | 7050 | case ZigTypeIdEnum: |
| 7051 | return bigint_to_llvm_const(get_llvm_type(g, type_entry), &const_val->data.x_enum_tag); | 7051 | return bigint_to_llvm_const(get_llvm_type(g, type_entry), &const_val->data.x_enum_tag); |
| 7052 | case ZigTypeIdFn: | 7052 | case ZigTypeIdFn: |
| 7053 | if (const_val->data.x_ptr.special == ConstPtrSpecialFunction) { | 7053 | if (const_val->data.x_ptr.special == ConstPtrSpecialFunction && |
| 7054 | assert(const_val->data.x_ptr.mut == ConstPtrMutComptimeConst); | 7054 | const_val->data.x_ptr.mut != ConstPtrMutComptimeConst) { |
| 7055 | return fn_llvm_value(g, const_val->data.x_ptr.data.fn.fn_entry); | ||
| 7056 | } else if (const_val->data.x_ptr.special == ConstPtrSpecialHardCodedAddr) { | ||
| 7057 | LLVMTypeRef usize_type_ref = g->builtin_types.entry_usize->llvm_type; | ||
| 7058 | uint64_t addr = const_val->data.x_ptr.data.hard_coded_addr.addr; | ||
| 7059 | return LLVMConstIntToPtr(LLVMConstInt(usize_type_ref, addr, false), get_llvm_type(g, type_entry)); | ||
| 7060 | } else { | ||
| 7061 | zig_unreachable(); | 7055 | zig_unreachable(); |
| 7062 | } | 7056 | } |
| 7057 | // Treat it the same as we do for pointers | ||
| 7058 | return gen_const_val_ptr(g, const_val, name); | ||
| 7063 | case ZigTypeIdPointer: | 7059 | case ZigTypeIdPointer: |
| 7064 | return gen_const_val_ptr(g, const_val, name); | 7060 | return gen_const_val_ptr(g, const_val, name); |
| 7065 | case ZigTypeIdErrorUnion: | 7061 | case ZigTypeIdErrorUnion: |
test/stage1/behavior/cast.zig+6| ... | @@ -559,3 +559,9 @@ test "peer cast *[0]T to []const T" { | ... | @@ -559,3 +559,9 @@ test "peer cast *[0]T to []const T" { |
| 559 | var y = if (b) &[0]u8{} else buf; | 559 | var y = if (b) &[0]u8{} else buf; |
| 560 | expect(mem.eql(u8, "abcde", y)); | 560 | expect(mem.eql(u8, "abcde", y)); |
| 561 | } | 561 | } |
| 562 | |||
| 563 | var global_array: [4]u8 = undefined; | ||
| 564 | test "cast from array reference to fn" { | ||
| 565 | const f = @ptrCast(extern fn () void, &global_array); | ||
| 566 | expect(@ptrToInt(f) == @ptrToInt(&global_array)); | ||
| 567 | } |