| author | |
| committer | |
| log | fdbc2d8da1c707859af8f8bb42a27ae9d3a62159 |
| tree | 1a1289cac097941e6bef0757a1c7e0fdf3c1668c |
| parent | 98faf4f74984db615ba62de285308dfc5092ec7c |
closes #484 files changed, 17 insertions(+), 5 deletions(-)
src/ir.cpp+4-2| ... | ... | @@ -8423,6 +8423,8 @@ static TypeTableEntry *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field |
| 8423 | 8423 | TypeTableEntry *bare_type = container_ref_type(container_type); |
| 8424 | 8424 | ensure_complete_type(ira->codegen, bare_type); |
| 8425 | 8425 | |
| 8426 | assert(container_ptr->value.type->id == TypeTableEntryIdPointer); | |
| 8427 | bool is_const = container_ptr->value.type->data.pointer.is_const; | |
| 8426 | 8428 | if (bare_type->id == TypeTableEntryIdStruct) { |
| 8427 | 8429 | if (bare_type->data.structure.is_invalid) |
| 8428 | 8430 | return ira->codegen->builtin_types.entry_invalid; |
| ... | ... | @@ -8430,7 +8432,7 @@ static TypeTableEntry *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field |
| 8430 | 8432 | TypeStructField *field = find_struct_type_field(bare_type, field_name); |
| 8431 | 8433 | if (field) { |
| 8432 | 8434 | ir_build_struct_field_ptr_from(&ira->new_irb, &field_ptr_instruction->base, container_ptr, field); |
| 8433 | return get_pointer_to_type(ira->codegen, field->type_entry, false); | |
| 8435 | return get_pointer_to_type(ira->codegen, field->type_entry, is_const); | |
| 8434 | 8436 | } else { |
| 8435 | 8437 | return ir_analyze_container_member_access_inner(ira, bare_type, field_name, |
| 8436 | 8438 | field_ptr_instruction, container_ptr, container_type); |
| ... | ... | @@ -8442,7 +8444,7 @@ static TypeTableEntry *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field |
| 8442 | 8444 | TypeEnumField *field = find_enum_type_field(bare_type, field_name); |
| 8443 | 8445 | if (field) { |
| 8444 | 8446 | ir_build_enum_field_ptr_from(&ira->new_irb, &field_ptr_instruction->base, container_ptr, field); |
| 8445 | return get_pointer_to_type(ira->codegen, field->type_entry, false); | |
| 8447 | return get_pointer_to_type(ira->codegen, field->type_entry, is_const); | |
| 8446 | 8448 | } else { |
| 8447 | 8449 | return ir_analyze_container_member_access_inner(ira, bare_type, field_name, |
| 8448 | 8450 | field_ptr_instruction, container_ptr, container_type); |
std/debug.zig+2-2| ... | ... | @@ -327,8 +327,8 @@ fn parseAbbrevTable(in_stream: &io.InStream) -> %AbbrevTable { |
| 327 | 327 | |
| 328 | 328 | /// Gets an already existing AbbrevTable given the abbrev_offset, or if not found, |
| 329 | 329 | /// seeks in the stream and parses it. |
| 330 | fn getAbbrevTable(st: &ElfStackTrace, abbrev_offset: u64) -> %&AbbrevTable { | |
| 331 | for (st.abbrev_table_list.toSlice()) |header| { | |
| 330 | fn getAbbrevTable(st: &ElfStackTrace, abbrev_offset: u64) -> %&const AbbrevTable { | |
| 331 | for (st.abbrev_table_list.toSlice()) |*header| { | |
| 332 | 332 | if (header.offset == abbrev_offset) { |
| 333 | 333 | return &header.table; |
| 334 | 334 | } |
test/run_tests.cpp+10| ... | ... | @@ -1595,6 +1595,16 @@ const zero: i32 = 0; |
| 1595 | 1595 | const a = zero{1}; |
| 1596 | 1596 | )SOURCE", 1, ".tmp_source.zig:3:11: error: expected type, found 'i32'"); |
| 1597 | 1597 | |
| 1598 | add_compile_fail_case("assign to constant field", R"SOURCE( | |
| 1599 | const Foo = struct { | |
| 1600 | field: i32, | |
| 1601 | }; | |
| 1602 | fn derp() { | |
| 1603 | const f = Foo {.field = 1234,}; | |
| 1604 | f.field = 0; | |
| 1605 | } | |
| 1606 | )SOURCE", 1, ".tmp_source.zig:7:13: error: cannot assign to constant"); | |
| 1607 | ||
| 1598 | 1608 | } |
| 1599 | 1609 | |
| 1600 | 1610 | ////////////////////////////////////////////////////////////////////////////// |
test/self_hosted.zig+1-1| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | const test_array = @import("cases/array.zig"); |
| 3 | 3 | const test_atomics = @import("cases/atomics.zig"); |
| 4 | 4 | const test_bool = @import("cases/bool.zig"); |
| 5 | const test_cast= @import("cases/cast.zig"); | |
| 5 | const test_cast = @import("cases/cast.zig"); | |
| 6 | 6 | const test_const_slice_child = @import("cases/const_slice_child.zig"); |
| 7 | 7 | const test_defer = @import("cases/defer.zig"); |
| 8 | 8 | const test_enum = @import("cases/enum.zig"); |