| author | |
| committer | |
| log | 5699ab5e77f8d13cac1e34775e6e51358119965c |
| tree | 00d8d677c008a7c7248861cb87fc415dd34816a4 |
| parent | 270933b1e997c91a9c2d28b6896d625c0ae1b163 |
| signature |
See #10594 files changed, 181 insertions(+), 89 deletions(-)
src/all_types.hpp+9-3| ... | ... | @@ -691,15 +691,17 @@ struct AstNodePointerType { |
| 691 | 691 | AstNode *align_expr; |
| 692 | 692 | BigInt *bit_offset_start; |
| 693 | 693 | BigInt *host_int_bytes; |
| 694 | AstNode *op_expr; | |
| 695 | Token *allow_zero_token; | |
| 694 | 696 | bool is_const; |
| 695 | 697 | bool is_volatile; |
| 696 | AstNode *op_expr; | |
| 697 | 698 | }; |
| 698 | 699 | |
| 699 | 700 | struct AstNodeArrayType { |
| 700 | 701 | AstNode *size; |
| 701 | 702 | AstNode *child_type; |
| 702 | 703 | AstNode *align_expr; |
| 704 | Token *allow_zero_token; | |
| 703 | 705 | bool is_const; |
| 704 | 706 | bool is_volatile; |
| 705 | 707 | }; |
| ... | ... | @@ -1050,6 +1052,7 @@ struct ZigTypePointer { |
| 1050 | 1052 | uint32_t host_int_bytes; // size of host integer. 0 means no host integer; this field is aligned |
| 1051 | 1053 | bool is_const; |
| 1052 | 1054 | bool is_volatile; |
| 1055 | bool allow_zero; | |
| 1053 | 1056 | }; |
| 1054 | 1057 | |
| 1055 | 1058 | struct ZigTypeInt { |
| ... | ... | @@ -1499,11 +1502,12 @@ struct TypeId { |
| 1499 | 1502 | struct { |
| 1500 | 1503 | ZigType *child_type; |
| 1501 | 1504 | PtrLen ptr_len; |
| 1502 | bool is_const; | |
| 1503 | bool is_volatile; | |
| 1504 | 1505 | uint32_t alignment; |
| 1505 | 1506 | uint32_t bit_offset_in_host; |
| 1506 | 1507 | uint32_t host_int_bytes; |
| 1508 | bool is_const; | |
| 1509 | bool is_volatile; | |
| 1510 | bool allow_zero; | |
| 1507 | 1511 | } pointer; |
| 1508 | 1512 | struct { |
| 1509 | 1513 | ZigType *child_type; |
| ... | ... | @@ -2592,6 +2596,7 @@ struct IrInstructionPtrType { |
| 2592 | 2596 | PtrLen ptr_len; |
| 2593 | 2597 | bool is_const; |
| 2594 | 2598 | bool is_volatile; |
| 2599 | bool allow_zero; | |
| 2595 | 2600 | }; |
| 2596 | 2601 | |
| 2597 | 2602 | struct IrInstructionPromiseType { |
| ... | ... | @@ -2607,6 +2612,7 @@ struct IrInstructionSliceType { |
| 2607 | 2612 | IrInstruction *child_type; |
| 2608 | 2613 | bool is_const; |
| 2609 | 2614 | bool is_volatile; |
| 2615 | bool allow_zero; | |
| 2610 | 2616 | }; |
| 2611 | 2617 | |
| 2612 | 2618 | struct IrInstructionAsm { |
src/analyze.cpp+33-12| ... | ... | @@ -433,6 +433,9 @@ ZigType *get_pointer_to_type_extra(CodeGen *g, ZigType *child_type, bool is_cons |
| 433 | 433 | bool is_volatile, PtrLen ptr_len, uint32_t byte_alignment, |
| 434 | 434 | uint32_t bit_offset_in_host, uint32_t host_int_bytes) |
| 435 | 435 | { |
| 436 | // TODO when implementing https://github.com/ziglang/zig/issues/1953 | |
| 437 | // move this to a parameter | |
| 438 | bool allow_zero = (ptr_len == PtrLenC); | |
| 436 | 439 | assert(!type_is_invalid(child_type)); |
| 437 | 440 | assert(ptr_len != PtrLenUnknown || child_type->id != ZigTypeIdOpaque); |
| 438 | 441 | |
| ... | ... | @@ -452,7 +455,7 @@ ZigType *get_pointer_to_type_extra(CodeGen *g, ZigType *child_type, bool is_cons |
| 452 | 455 | |
| 453 | 456 | TypeId type_id = {}; |
| 454 | 457 | ZigType **parent_pointer = nullptr; |
| 455 | if (host_int_bytes != 0 || is_volatile || byte_alignment != 0 || ptr_len != PtrLenSingle) { | |
| 458 | if (host_int_bytes != 0 || is_volatile || byte_alignment != 0 || ptr_len != PtrLenSingle || allow_zero) { | |
| 456 | 459 | type_id.id = ZigTypeIdPointer; |
| 457 | 460 | type_id.data.pointer.child_type = child_type; |
| 458 | 461 | type_id.data.pointer.is_const = is_const; |
| ... | ... | @@ -461,6 +464,7 @@ ZigType *get_pointer_to_type_extra(CodeGen *g, ZigType *child_type, bool is_cons |
| 461 | 464 | type_id.data.pointer.bit_offset_in_host = bit_offset_in_host; |
| 462 | 465 | type_id.data.pointer.host_int_bytes = host_int_bytes; |
| 463 | 466 | type_id.data.pointer.ptr_len = ptr_len; |
| 467 | type_id.data.pointer.allow_zero = allow_zero; | |
| 464 | 468 | |
| 465 | 469 | auto existing_entry = g->type_table.maybe_get(type_id); |
| 466 | 470 | if (existing_entry) |
| ... | ... | @@ -481,18 +485,28 @@ ZigType *get_pointer_to_type_extra(CodeGen *g, ZigType *child_type, bool is_cons |
| 481 | 485 | const char *star_str = ptr_len_to_star_str(ptr_len); |
| 482 | 486 | const char *const_str = is_const ? "const " : ""; |
| 483 | 487 | const char *volatile_str = is_volatile ? "volatile " : ""; |
| 488 | const char *allow_zero_str; | |
| 489 | if (ptr_len == PtrLenC) { | |
| 490 | assert(allow_zero); | |
| 491 | allow_zero_str = ""; | |
| 492 | } else { | |
| 493 | allow_zero_str = allow_zero ? "allowzero " : ""; | |
| 494 | } | |
| 484 | 495 | buf_resize(&entry->name, 0); |
| 485 | 496 | if (host_int_bytes == 0 && byte_alignment == 0) { |
| 486 | buf_appendf(&entry->name, "%s%s%s%s", star_str, const_str, volatile_str, buf_ptr(&child_type->name)); | |
| 497 | buf_appendf(&entry->name, "%s%s%s%s%s", | |
| 498 | star_str, const_str, volatile_str, allow_zero_str, buf_ptr(&child_type->name)); | |
| 487 | 499 | } else if (host_int_bytes == 0) { |
| 488 | buf_appendf(&entry->name, "%salign(%" PRIu32 ") %s%s%s", star_str, byte_alignment, | |
| 489 | const_str, volatile_str, buf_ptr(&child_type->name)); | |
| 500 | buf_appendf(&entry->name, "%salign(%" PRIu32 ") %s%s%s%s", star_str, byte_alignment, | |
| 501 | const_str, volatile_str, allow_zero_str, buf_ptr(&child_type->name)); | |
| 490 | 502 | } else if (byte_alignment == 0) { |
| 491 | buf_appendf(&entry->name, "%salign(:%" PRIu32 ":%" PRIu32 ") %s%s%s", star_str, | |
| 492 | bit_offset_in_host, host_int_bytes, const_str, volatile_str, buf_ptr(&child_type->name)); | |
| 503 | buf_appendf(&entry->name, "%salign(:%" PRIu32 ":%" PRIu32 ") %s%s%s%s", star_str, | |
| 504 | bit_offset_in_host, host_int_bytes, const_str, volatile_str, allow_zero_str, | |
| 505 | buf_ptr(&child_type->name)); | |
| 493 | 506 | } else { |
| 494 | buf_appendf(&entry->name, "%salign(%" PRIu32 ":%" PRIu32 ":%" PRIu32 ") %s%s%s", star_str, byte_alignment, | |
| 495 | bit_offset_in_host, host_int_bytes, const_str, volatile_str, buf_ptr(&child_type->name)); | |
| 507 | buf_appendf(&entry->name, "%salign(%" PRIu32 ":%" PRIu32 ":%" PRIu32 ") %s%s%s%s", star_str, byte_alignment, | |
| 508 | bit_offset_in_host, host_int_bytes, const_str, volatile_str, allow_zero_str, | |
| 509 | buf_ptr(&child_type->name)); | |
| 496 | 510 | } |
| 497 | 511 | |
| 498 | 512 | assert(child_type->id != ZigTypeIdInvalid); |
| ... | ... | @@ -500,7 +514,9 @@ ZigType *get_pointer_to_type_extra(CodeGen *g, ZigType *child_type, bool is_cons |
| 500 | 514 | entry->zero_bits = !type_has_bits(child_type); |
| 501 | 515 | |
| 502 | 516 | if (!entry->zero_bits) { |
| 503 | if (is_const || is_volatile || byte_alignment != 0 || ptr_len != PtrLenSingle || bit_offset_in_host != 0) { | |
| 517 | if (is_const || is_volatile || byte_alignment != 0 || ptr_len != PtrLenSingle || | |
| 518 | bit_offset_in_host != 0 || allow_zero) | |
| 519 | { | |
| 504 | 520 | ZigType *peer_type = get_pointer_to_type_extra(g, child_type, false, false, |
| 505 | 521 | PtrLenSingle, 0, 0, host_int_bytes); |
| 506 | 522 | entry->type_ref = peer_type->type_ref; |
| ... | ... | @@ -534,6 +550,7 @@ ZigType *get_pointer_to_type_extra(CodeGen *g, ZigType *child_type, bool is_cons |
| 534 | 550 | entry->data.pointer.explicit_alignment = byte_alignment; |
| 535 | 551 | entry->data.pointer.bit_offset_in_host = bit_offset_in_host; |
| 536 | 552 | entry->data.pointer.host_int_bytes = host_int_bytes; |
| 553 | entry->data.pointer.allow_zero = allow_zero; | |
| 537 | 554 | |
| 538 | 555 | if (parent_pointer) { |
| 539 | 556 | *parent_pointer = entry; |
| ... | ... | @@ -850,7 +867,7 @@ ZigType *get_slice_type(CodeGen *g, ZigType *ptr_type) { |
| 850 | 867 | |
| 851 | 868 | ZigType *child_type = ptr_type->data.pointer.child_type; |
| 852 | 869 | if (ptr_type->data.pointer.is_const || ptr_type->data.pointer.is_volatile || |
| 853 | ptr_type->data.pointer.explicit_alignment != 0) | |
| 870 | ptr_type->data.pointer.explicit_alignment != 0 || ptr_type->data.pointer.allow_zero) | |
| 854 | 871 | { |
| 855 | 872 | ZigType *peer_ptr_type = get_pointer_to_type_extra(g, child_type, false, false, |
| 856 | 873 | PtrLenUnknown, 0, 0, 0); |
| ... | ... | @@ -873,7 +890,7 @@ ZigType *get_slice_type(CodeGen *g, ZigType *ptr_type) { |
| 873 | 890 | ZigType *child_ptr_type = child_type->data.structure.fields[slice_ptr_index].type_entry; |
| 874 | 891 | assert(child_ptr_type->id == ZigTypeIdPointer); |
| 875 | 892 | if (child_ptr_type->data.pointer.is_const || child_ptr_type->data.pointer.is_volatile || |
| 876 | child_ptr_type->data.pointer.explicit_alignment != 0) | |
| 893 | child_ptr_type->data.pointer.explicit_alignment != 0 || child_ptr_type->data.pointer.allow_zero) | |
| 877 | 894 | { |
| 878 | 895 | ZigType *grand_child_type = child_ptr_type->data.pointer.child_type; |
| 879 | 896 | ZigType *bland_child_ptr_type = get_pointer_to_type_extra(g, grand_child_type, false, false, |
| ... | ... | @@ -4053,7 +4070,9 @@ ZigType *get_src_ptr_type(ZigType *type) { |
| 4053 | 4070 | if (type->id == ZigTypeIdFn) return type; |
| 4054 | 4071 | if (type->id == ZigTypeIdPromise) return type; |
| 4055 | 4072 | if (type->id == ZigTypeIdOptional) { |
| 4056 | if (type->data.maybe.child_type->id == ZigTypeIdPointer) return type->data.maybe.child_type; | |
| 4073 | if (type->data.maybe.child_type->id == ZigTypeIdPointer) { | |
| 4074 | return type->data.maybe.child_type->data.pointer.allow_zero ? nullptr : type->data.maybe.child_type; | |
| 4075 | } | |
| 4057 | 4076 | if (type->data.maybe.child_type->id == ZigTypeIdFn) return type->data.maybe.child_type; |
| 4058 | 4077 | if (type->data.maybe.child_type->id == ZigTypeIdPromise) return type->data.maybe.child_type; |
| 4059 | 4078 | } |
| ... | ... | @@ -6289,6 +6308,7 @@ uint32_t type_id_hash(TypeId x) { |
| 6289 | 6308 | ((x.data.pointer.ptr_len == PtrLenSingle) ? (uint32_t)1120226602 : (uint32_t)3200913342) + |
| 6290 | 6309 | (x.data.pointer.is_const ? (uint32_t)2749109194 : (uint32_t)4047371087) + |
| 6291 | 6310 | (x.data.pointer.is_volatile ? (uint32_t)536730450 : (uint32_t)1685612214) + |
| 6311 | (x.data.pointer.allow_zero ? (uint32_t)3324284834 : (uint32_t)3584904923) + | |
| 6292 | 6312 | (((uint32_t)x.data.pointer.alignment) ^ (uint32_t)0x777fbe0e) + |
| 6293 | 6313 | (((uint32_t)x.data.pointer.bit_offset_in_host) ^ (uint32_t)2639019452) + |
| 6294 | 6314 | (((uint32_t)x.data.pointer.host_int_bytes) ^ (uint32_t)529908881); |
| ... | ... | @@ -6339,6 +6359,7 @@ bool type_id_eql(TypeId a, TypeId b) { |
| 6339 | 6359 | a.data.pointer.ptr_len == b.data.pointer.ptr_len && |
| 6340 | 6360 | a.data.pointer.is_const == b.data.pointer.is_const && |
| 6341 | 6361 | a.data.pointer.is_volatile == b.data.pointer.is_volatile && |
| 6362 | a.data.pointer.allow_zero == b.data.pointer.allow_zero && | |
| 6342 | 6363 | a.data.pointer.alignment == b.data.pointer.alignment && |
| 6343 | 6364 | a.data.pointer.bit_offset_in_host == b.data.pointer.bit_offset_in_host && |
| 6344 | 6365 | a.data.pointer.host_int_bytes == b.data.pointer.host_int_bytes; |
src/ir.cpp+70-29| ... | ... | @@ -61,7 +61,7 @@ enum ConstCastResultId { |
| 61 | 61 | ConstCastResultIdType, |
| 62 | 62 | ConstCastResultIdUnresolvedInferredErrSet, |
| 63 | 63 | ConstCastResultIdAsyncAllocatorType, |
| 64 | ConstCastResultIdNullWrapPtr | |
| 64 | ConstCastResultIdBadAllowsZero, | |
| 65 | 65 | }; |
| 66 | 66 | |
| 67 | 67 | struct ConstCastOnly; |
| ... | ... | @@ -83,6 +83,7 @@ struct ConstCastErrUnionErrSetMismatch; |
| 83 | 83 | struct ConstCastErrUnionPayloadMismatch; |
| 84 | 84 | struct ConstCastErrSetMismatch; |
| 85 | 85 | struct ConstCastTypeMismatch; |
| 86 | struct ConstCastBadAllowsZero; | |
| 86 | 87 | |
| 87 | 88 | struct ConstCastOnly { |
| 88 | 89 | ConstCastResultId id; |
| ... | ... | @@ -99,6 +100,7 @@ struct ConstCastOnly { |
| 99 | 100 | ConstCastOnly *null_wrap_ptr_child; |
| 100 | 101 | ConstCastArg fn_arg; |
| 101 | 102 | ConstCastArgNoAlias arg_no_alias; |
| 103 | ConstCastBadAllowsZero *bad_allows_zero; | |
| 102 | 104 | } data; |
| 103 | 105 | }; |
| 104 | 106 | |
| ... | ... | @@ -141,6 +143,12 @@ struct ConstCastErrSetMismatch { |
| 141 | 143 | ZigList<ErrorTableEntry *> missing_errors; |
| 142 | 144 | }; |
| 143 | 145 | |
| 146 | struct ConstCastBadAllowsZero { | |
| 147 | ZigType *wanted_type; | |
| 148 | ZigType *actual_type; | |
| 149 | }; | |
| 150 | ||
| 151 | ||
| 144 | 152 | enum UndefAllowed { |
| 145 | 153 | UndefOk, |
| 146 | 154 | UndefBad, |
| ... | ... | @@ -8636,6 +8644,14 @@ static ZigType *get_error_set_intersection(IrAnalyze *ira, ZigType *set1, ZigTyp |
| 8636 | 8644 | return err_set_type; |
| 8637 | 8645 | } |
| 8638 | 8646 | |
| 8647 | static bool ptr_allows_addr_zero(ZigType *ptr_type) { | |
| 8648 | if (ptr_type->id == ZigTypeIdPointer) { | |
| 8649 | return ptr_type->data.pointer.allow_zero; | |
| 8650 | } else if (ptr_type->id == ZigTypeIdOptional) { | |
| 8651 | return true; | |
| 8652 | } | |
| 8653 | return false; | |
| 8654 | } | |
| 8639 | 8655 | |
| 8640 | 8656 | static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted_type, |
| 8641 | 8657 | ZigType *actual_type, AstNode *source_node, bool wanted_is_mutable) |
| ... | ... | @@ -8649,34 +8665,35 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted |
| 8649 | 8665 | if (wanted_type == actual_type) |
| 8650 | 8666 | return result; |
| 8651 | 8667 | |
| 8652 | // *T and [*]T may const-cast-only to ?*U and ?[*]U, respectively | |
| 8653 | // but not if we want a mutable pointer | |
| 8654 | // and not if the actual pointer has zero bits | |
| 8655 | if (!wanted_is_mutable && wanted_type->id == ZigTypeIdOptional && | |
| 8656 | wanted_type->data.maybe.child_type->id == ZigTypeIdPointer && | |
| 8657 | actual_type->id == ZigTypeIdPointer && type_has_bits(actual_type)) | |
| 8658 | { | |
| 8659 | ConstCastOnly child = types_match_const_cast_only(ira, | |
| 8660 | wanted_type->data.maybe.child_type, actual_type, source_node, wanted_is_mutable); | |
| 8661 | if (child.id == ConstCastResultIdInvalid) | |
| 8662 | return child; | |
| 8663 | if (child.id != ConstCastResultIdOk) { | |
| 8664 | result.id = ConstCastResultIdNullWrapPtr; | |
| 8665 | result.data.null_wrap_ptr_child = allocate_nonzero<ConstCastOnly>(1); | |
| 8666 | *result.data.null_wrap_ptr_child = child; | |
| 8667 | } | |
| 8668 | return result; | |
| 8669 | } | |
| 8670 | ||
| 8671 | // pointer const | |
| 8668 | // If pointers have the same representation in memory, they can be "const-casted". | |
| 8669 | // `const` attribute can be gained | |
| 8670 | // `volatile` attribute can be gained | |
| 8671 | // `allowzero` attribute can be gained (whether from explicit attribute, C pointer, or optional pointer) | |
| 8672 | // but only if !wanted_is_mutable | |
| 8673 | // alignment can be decreased | |
| 8674 | // bit offset attributes must match exactly | |
| 8675 | // PtrLenSingle/PtrLenUnknown must match exactly, but PtrLenC matches either one | |
| 8672 | 8676 | ZigType *wanted_ptr_type = get_src_ptr_type(wanted_type); |
| 8673 | 8677 | ZigType *actual_ptr_type = get_src_ptr_type(actual_type); |
| 8678 | bool wanted_allows_zero = ptr_allows_addr_zero(wanted_type); | |
| 8679 | bool actual_allows_zero = ptr_allows_addr_zero(actual_type); | |
| 8674 | 8680 | bool wanted_is_c_ptr = wanted_type->id == ZigTypeIdPointer && wanted_type->data.pointer.ptr_len == PtrLenC; |
| 8675 | 8681 | bool actual_is_c_ptr = actual_type->id == ZigTypeIdPointer && actual_type->data.pointer.ptr_len == PtrLenC; |
| 8676 | if ((wanted_type->id == ZigTypeIdPointer && actual_type->id == ZigTypeIdPointer) || | |
| 8677 | (wanted_ptr_type != nullptr && actual_is_c_ptr) || | |
| 8678 | (actual_ptr_type != nullptr && wanted_is_c_ptr)) | |
| 8679 | { | |
| 8682 | bool wanted_opt_or_ptr = wanted_ptr_type != nullptr && | |
| 8683 | (wanted_type->id == ZigTypeIdPointer || wanted_type->id == ZigTypeIdOptional); | |
| 8684 | bool actual_opt_or_ptr = actual_ptr_type != nullptr && | |
| 8685 | (actual_type->id == ZigTypeIdPointer || actual_type->id == ZigTypeIdOptional); | |
| 8686 | if (wanted_opt_or_ptr && actual_opt_or_ptr) { | |
| 8687 | bool ok_allows_zero = (wanted_allows_zero && | |
| 8688 | (actual_allows_zero || wanted_ptr_type->data.pointer.is_const)) || | |
| 8689 | (!wanted_allows_zero && !actual_allows_zero); | |
| 8690 | if (!ok_allows_zero) { | |
| 8691 | result.id = ConstCastResultIdBadAllowsZero; | |
| 8692 | result.data.bad_allows_zero = allocate_nonzero<ConstCastBadAllowsZero>(1); | |
| 8693 | result.data.bad_allows_zero->wanted_type = wanted_type; | |
| 8694 | result.data.bad_allows_zero->actual_type = actual_type; | |
| 8695 | return result; | |
| 8696 | } | |
| 8680 | 8697 | ConstCastOnly child = types_match_const_cast_only(ira, wanted_ptr_type->data.pointer.child_type, |
| 8681 | 8698 | actual_ptr_type->data.pointer.child_type, source_node, !wanted_ptr_type->data.pointer.is_const); |
| 8682 | 8699 | if (child.id == ConstCastResultIdInvalid) |
| ... | ... | @@ -8699,6 +8716,7 @@ static ConstCastOnly types_match_const_cast_only(IrAnalyze *ira, ZigType *wanted |
| 8699 | 8716 | } |
| 8700 | 8717 | bool ptr_lens_equal = actual_ptr_type->data.pointer.ptr_len == wanted_ptr_type->data.pointer.ptr_len; |
| 8701 | 8718 | if ((ptr_lens_equal || wanted_is_c_ptr || actual_is_c_ptr) && |
| 8719 | type_has_bits(wanted_type) == type_has_bits(actual_type) && | |
| 8702 | 8720 | (!actual_ptr_type->data.pointer.is_const || wanted_ptr_type->data.pointer.is_const) && |
| 8703 | 8721 | (!actual_ptr_type->data.pointer.is_volatile || wanted_ptr_type->data.pointer.is_volatile) && |
| 8704 | 8722 | actual_ptr_type->data.pointer.bit_offset_in_host == wanted_ptr_type->data.pointer.bit_offset_in_host && |
| ... | ... | @@ -9922,7 +9940,7 @@ static ConstExprValue *ir_resolve_const(IrAnalyze *ira, IrInstruction *value, Un |
| 9922 | 9940 | if (undef_allowed == UndefOk) { |
| 9923 | 9941 | return &value->value; |
| 9924 | 9942 | } else { |
| 9925 | ir_add_error(ira, value, buf_sprintf("use of undefined value")); | |
| 9943 | ir_add_error(ira, value, buf_sprintf("use of undefined value here causes undefined behavior")); | |
| 9926 | 9944 | return nullptr; |
| 9927 | 9945 | } |
| 9928 | 9946 | } |
| ... | ... | @@ -10828,6 +10846,26 @@ static void report_recursive_error(IrAnalyze *ira, AstNode *source_node, ConstCa |
| 10828 | 10846 | report_recursive_error(ira, source_node, cast_result->data.fn_arg.child, msg); |
| 10829 | 10847 | break; |
| 10830 | 10848 | } |
| 10849 | case ConstCastResultIdBadAllowsZero: { | |
| 10850 | bool wanted_allows_zero = ptr_allows_addr_zero(cast_result->data.bad_allows_zero->wanted_type); | |
| 10851 | bool actual_allows_zero = ptr_allows_addr_zero(cast_result->data.bad_allows_zero->actual_type); | |
| 10852 | ZigType *wanted_ptr_type = get_src_ptr_type(cast_result->data.bad_allows_zero->wanted_type); | |
| 10853 | ZigType *actual_ptr_type = get_src_ptr_type(cast_result->data.bad_allows_zero->actual_type); | |
| 10854 | ZigType *wanted_elem_type = wanted_ptr_type->data.pointer.child_type; | |
| 10855 | ZigType *actual_elem_type = actual_ptr_type->data.pointer.child_type; | |
| 10856 | if (actual_allows_zero && !wanted_allows_zero) { | |
| 10857 | add_error_note(ira->codegen, parent_msg, source_node, | |
| 10858 | buf_sprintf("'%s' could have null values which are illegal in type '%s'", | |
| 10859 | buf_ptr(&actual_elem_type->name), | |
| 10860 | buf_ptr(&wanted_elem_type->name))); | |
| 10861 | } else { | |
| 10862 | add_error_note(ira->codegen, parent_msg, source_node, | |
| 10863 | buf_sprintf("mutable '%s' allows illegal null values stored to type '%s'", | |
| 10864 | buf_ptr(&cast_result->data.bad_allows_zero->wanted_type->name), | |
| 10865 | buf_ptr(&cast_result->data.bad_allows_zero->actual_type->name))); | |
| 10866 | } | |
| 10867 | break; | |
| 10868 | } | |
| 10831 | 10869 | case ConstCastResultIdFnAlign: // TODO |
| 10832 | 10870 | case ConstCastResultIdFnCC: // TODO |
| 10833 | 10871 | case ConstCastResultIdFnVarArgs: // TODO |
| ... | ... | @@ -10838,7 +10876,6 @@ static void report_recursive_error(IrAnalyze *ira, AstNode *source_node, ConstCa |
| 10838 | 10876 | case ConstCastResultIdFnArgNoAlias: // TODO |
| 10839 | 10877 | case ConstCastResultIdUnresolvedInferredErrSet: // TODO |
| 10840 | 10878 | case ConstCastResultIdAsyncAllocatorType: // TODO |
| 10841 | case ConstCastResultIdNullWrapPtr: // TODO | |
| 10842 | 10879 | break; |
| 10843 | 10880 | } |
| 10844 | 10881 | } |
| ... | ... | @@ -20589,12 +20626,14 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ |
| 20589 | 20626 | // We have a check for zero bits later so we use get_src_ptr_type to |
| 20590 | 20627 | // validate src_type and dest_type. |
| 20591 | 20628 | |
| 20592 | if (get_src_ptr_type(src_type) == nullptr) { | |
| 20629 | ZigType *src_ptr_type = get_src_ptr_type(src_type); | |
| 20630 | if (src_ptr_type == nullptr) { | |
| 20593 | 20631 | ir_add_error(ira, ptr, buf_sprintf("expected pointer, found '%s'", buf_ptr(&src_type->name))); |
| 20594 | 20632 | return ira->codegen->invalid_instruction; |
| 20595 | 20633 | } |
| 20596 | 20634 | |
| 20597 | if (get_src_ptr_type(dest_type) == nullptr) { | |
| 20635 | ZigType *dest_ptr_type = get_src_ptr_type(dest_type); | |
| 20636 | if (dest_ptr_type == nullptr) { | |
| 20598 | 20637 | ir_add_error(ira, dest_type_src, |
| 20599 | 20638 | buf_sprintf("expected pointer, found '%s'", buf_ptr(&dest_type->name))); |
| 20600 | 20639 | return ira->codegen->invalid_instruction; |
| ... | ... | @@ -20606,6 +20645,8 @@ static IrInstruction *ir_analyze_ptr_cast(IrAnalyze *ira, IrInstruction *source_ |
| 20606 | 20645 | } |
| 20607 | 20646 | |
| 20608 | 20647 | if (instr_is_comptime(ptr)) { |
| 20648 | // Undefined is OK here; @ptrCast is defined to reinterpret the bit pattern | |
| 20649 | // of the pointer as the new pointer type. | |
| 20609 | 20650 | ConstExprValue *val = ir_resolve_const(ira, ptr, UndefOk); |
| 20610 | 20651 | if (!val) |
| 20611 | 20652 | return ira->codegen->invalid_instruction; |
test/compile_errors.zig+69-45| ... | ... | @@ -1,6 +1,30 @@ |
| 1 | 1 | const tests = @import("tests.zig"); |
| 2 | 2 | |
| 3 | 3 | pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 4 | cases.addTest( | |
| 5 | "implicit casting C pointers which would mess up null semantics", | |
| 6 | \\export fn entry() void { | |
| 7 | \\ var slice: []const u8 = "aoeu"; | |
| 8 | \\ const opt_many_ptr: [*]const u8 = slice.ptr; | |
| 9 | \\ var ptr_opt_many_ptr = &opt_many_ptr; | |
| 10 | \\ var c_ptr: [*c]const [*c]const u8 = ptr_opt_many_ptr; | |
| 11 | \\ ptr_opt_many_ptr = c_ptr; | |
| 12 | \\} | |
| 13 | \\export fn entry2() void { | |
| 14 | \\ var buf: [4]u8 = "aoeu"; | |
| 15 | \\ var slice: []u8 = &buf; | |
| 16 | \\ var opt_many_ptr: [*]u8 = slice.ptr; | |
| 17 | \\ var ptr_opt_many_ptr = &opt_many_ptr; | |
| 18 | \\ var c_ptr: [*c]const [*c]u8 = ptr_opt_many_ptr; | |
| 19 | \\} | |
| 20 | , | |
| 21 | ".tmp_source.zig:6:24: error: expected type '*const [*]const u8', found '[*c]const [*c]const u8'", | |
| 22 | ".tmp_source.zig:6:24: note: '[*c]const u8' could have null values which are illegal in type '[*]const u8'", | |
| 23 | ".tmp_source.zig:13:35: error: expected type '[*c]const [*c]u8', found '*[*]u8'", | |
| 24 | ".tmp_source.zig:13:35: note: pointer type child '[*]u8' cannot cast into pointer type child '[*c]u8'", | |
| 25 | ".tmp_source.zig:13:35: note: mutable '[*c]u8' allows illegal null values stored to type '[*]u8'", | |
| 26 | ); | |
| 27 | ||
| 4 | 28 | cases.addTest( |
| 5 | 29 | "implicit casting too big integers to C pointers", |
| 6 | 30 | \\export fn a() void { |
| ... | ... | @@ -31,7 +55,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 31 | 55 | \\ var z = @truncate(u8, u16(undefined)); |
| 32 | 56 | \\} |
| 33 | 57 | , |
| 34 | ".tmp_source.zig:2:30: error: use of undefined value", | |
| 58 | ".tmp_source.zig:2:30: error: use of undefined value here causes undefined behavior", | |
| 35 | 59 | ); |
| 36 | 60 | |
| 37 | 61 | cases.addTest( |
| ... | ... | @@ -392,7 +416,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 392 | 416 | \\ f(i32); |
| 393 | 417 | \\} |
| 394 | 418 | , |
| 395 | ".tmp_source.zig:4:5: error: use of undefined value", | |
| 419 | ".tmp_source.zig:4:5: error: use of undefined value here causes undefined behavior", | |
| 396 | 420 | ); |
| 397 | 421 | |
| 398 | 422 | cases.add( |
| ... | ... | @@ -792,7 +816,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 792 | 816 | \\ command.exec(); |
| 793 | 817 | \\} |
| 794 | 818 | , |
| 795 | ".tmp_source.zig:6:12: error: use of undefined value", | |
| 819 | ".tmp_source.zig:6:12: error: use of undefined value here causes undefined behavior", | |
| 796 | 820 | ); |
| 797 | 821 | |
| 798 | 822 | cases.add( |
| ... | ... | @@ -805,7 +829,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 805 | 829 | \\ command.exec(); |
| 806 | 830 | \\} |
| 807 | 831 | , |
| 808 | ".tmp_source.zig:6:12: error: use of undefined value", | |
| 832 | ".tmp_source.zig:6:12: error: use of undefined value here causes undefined behavior", | |
| 809 | 833 | ); |
| 810 | 834 | |
| 811 | 835 | cases.add( |
| ... | ... | @@ -2776,7 +2800,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 2776 | 2800 | \\ |
| 2777 | 2801 | \\export fn entry() usize { return @sizeOf(@typeOf(x)); } |
| 2778 | 2802 | , |
| 2779 | ".tmp_source.zig:1:15: error: use of undefined value", | |
| 2803 | ".tmp_source.zig:1:15: error: use of undefined value here causes undefined behavior", | |
| 2780 | 2804 | ); |
| 2781 | 2805 | |
| 2782 | 2806 | cases.add( |
| ... | ... | @@ -2786,7 +2810,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 2786 | 2810 | \\ _ = a / a; |
| 2787 | 2811 | \\} |
| 2788 | 2812 | , |
| 2789 | ".tmp_source.zig:3:9: error: use of undefined value", | |
| 2813 | ".tmp_source.zig:3:9: error: use of undefined value here causes undefined behavior", | |
| 2790 | 2814 | ); |
| 2791 | 2815 | |
| 2792 | 2816 | cases.add( |
| ... | ... | @@ -2796,7 +2820,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 2796 | 2820 | \\ a /= a; |
| 2797 | 2821 | \\} |
| 2798 | 2822 | , |
| 2799 | ".tmp_source.zig:3:5: error: use of undefined value", | |
| 2823 | ".tmp_source.zig:3:5: error: use of undefined value here causes undefined behavior", | |
| 2800 | 2824 | ); |
| 2801 | 2825 | |
| 2802 | 2826 | cases.add( |
| ... | ... | @@ -2806,7 +2830,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 2806 | 2830 | \\ _ = a % a; |
| 2807 | 2831 | \\} |
| 2808 | 2832 | , |
| 2809 | ".tmp_source.zig:3:9: error: use of undefined value", | |
| 2833 | ".tmp_source.zig:3:9: error: use of undefined value here causes undefined behavior", | |
| 2810 | 2834 | ); |
| 2811 | 2835 | |
| 2812 | 2836 | cases.add( |
| ... | ... | @@ -2816,7 +2840,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 2816 | 2840 | \\ a %= a; |
| 2817 | 2841 | \\} |
| 2818 | 2842 | , |
| 2819 | ".tmp_source.zig:3:5: error: use of undefined value", | |
| 2843 | ".tmp_source.zig:3:5: error: use of undefined value here causes undefined behavior", | |
| 2820 | 2844 | ); |
| 2821 | 2845 | |
| 2822 | 2846 | cases.add( |
| ... | ... | @@ -2826,7 +2850,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 2826 | 2850 | \\ _ = a + a; |
| 2827 | 2851 | \\} |
| 2828 | 2852 | , |
| 2829 | ".tmp_source.zig:3:9: error: use of undefined value", | |
| 2853 | ".tmp_source.zig:3:9: error: use of undefined value here causes undefined behavior", | |
| 2830 | 2854 | ); |
| 2831 | 2855 | |
| 2832 | 2856 | cases.add( |
| ... | ... | @@ -2836,7 +2860,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 2836 | 2860 | \\ a += a; |
| 2837 | 2861 | \\} |
| 2838 | 2862 | , |
| 2839 | ".tmp_source.zig:3:5: error: use of undefined value", | |
| 2863 | ".tmp_source.zig:3:5: error: use of undefined value here causes undefined behavior", | |
| 2840 | 2864 | ); |
| 2841 | 2865 | |
| 2842 | 2866 | cases.add( |
| ... | ... | @@ -2846,7 +2870,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 2846 | 2870 | \\ _ = a +% a; |
| 2847 | 2871 | \\} |
| 2848 | 2872 | , |
| 2849 | ".tmp_source.zig:3:9: error: use of undefined value", | |
| 2873 | ".tmp_source.zig:3:9: error: use of undefined value here causes undefined behavior", | |
| 2850 | 2874 | ); |
| 2851 | 2875 | |
| 2852 | 2876 | cases.add( |
| ... | ... | @@ -2856,7 +2880,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 2856 | 2880 | \\ a +%= a; |
| 2857 | 2881 | \\} |
| 2858 | 2882 | , |
| 2859 | ".tmp_source.zig:3:5: error: use of undefined value", | |
| 2883 | ".tmp_source.zig:3:5: error: use of undefined value here causes undefined behavior", | |
| 2860 | 2884 | ); |
| 2861 | 2885 | |
| 2862 | 2886 | cases.add( |
| ... | ... | @@ -2866,7 +2890,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 2866 | 2890 | \\ _ = a - a; |
| 2867 | 2891 | \\} |
| 2868 | 2892 | , |
| 2869 | ".tmp_source.zig:3:9: error: use of undefined value", | |
| 2893 | ".tmp_source.zig:3:9: error: use of undefined value here causes undefined behavior", | |
| 2870 | 2894 | ); |
| 2871 | 2895 | |
| 2872 | 2896 | cases.add( |
| ... | ... | @@ -2876,7 +2900,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 2876 | 2900 | \\ a -= a; |
| 2877 | 2901 | \\} |
| 2878 | 2902 | , |
| 2879 | ".tmp_source.zig:3:5: error: use of undefined value", | |
| 2903 | ".tmp_source.zig:3:5: error: use of undefined value here causes undefined behavior", | |
| 2880 | 2904 | ); |
| 2881 | 2905 | |
| 2882 | 2906 | cases.add( |
| ... | ... | @@ -2886,7 +2910,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 2886 | 2910 | \\ _ = a -% a; |
| 2887 | 2911 | \\} |
| 2888 | 2912 | , |
| 2889 | ".tmp_source.zig:3:9: error: use of undefined value", | |
| 2913 | ".tmp_source.zig:3:9: error: use of undefined value here causes undefined behavior", | |
| 2890 | 2914 | ); |
| 2891 | 2915 | |
| 2892 | 2916 | cases.add( |
| ... | ... | @@ -2896,7 +2920,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 2896 | 2920 | \\ a -%= a; |
| 2897 | 2921 | \\} |
| 2898 | 2922 | , |
| 2899 | ".tmp_source.zig:3:5: error: use of undefined value", | |
| 2923 | ".tmp_source.zig:3:5: error: use of undefined value here causes undefined behavior", | |
| 2900 | 2924 | ); |
| 2901 | 2925 | |
| 2902 | 2926 | cases.add( |
| ... | ... | @@ -2906,7 +2930,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 2906 | 2930 | \\ _ = a * a; |
| 2907 | 2931 | \\} |
| 2908 | 2932 | , |
| 2909 | ".tmp_source.zig:3:9: error: use of undefined value", | |
| 2933 | ".tmp_source.zig:3:9: error: use of undefined value here causes undefined behavior", | |
| 2910 | 2934 | ); |
| 2911 | 2935 | |
| 2912 | 2936 | cases.add( |
| ... | ... | @@ -2916,7 +2940,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 2916 | 2940 | \\ a *= a; |
| 2917 | 2941 | \\} |
| 2918 | 2942 | , |
| 2919 | ".tmp_source.zig:3:5: error: use of undefined value", | |
| 2943 | ".tmp_source.zig:3:5: error: use of undefined value here causes undefined behavior", | |
| 2920 | 2944 | ); |
| 2921 | 2945 | |
| 2922 | 2946 | cases.add( |
| ... | ... | @@ -2926,7 +2950,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 2926 | 2950 | \\ _ = a *% a; |
| 2927 | 2951 | \\} |
| 2928 | 2952 | , |
| 2929 | ".tmp_source.zig:3:9: error: use of undefined value", | |
| 2953 | ".tmp_source.zig:3:9: error: use of undefined value here causes undefined behavior", | |
| 2930 | 2954 | ); |
| 2931 | 2955 | |
| 2932 | 2956 | cases.add( |
| ... | ... | @@ -2936,7 +2960,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 2936 | 2960 | \\ a *%= a; |
| 2937 | 2961 | \\} |
| 2938 | 2962 | , |
| 2939 | ".tmp_source.zig:3:5: error: use of undefined value", | |
| 2963 | ".tmp_source.zig:3:5: error: use of undefined value here causes undefined behavior", | |
| 2940 | 2964 | ); |
| 2941 | 2965 | |
| 2942 | 2966 | cases.add( |
| ... | ... | @@ -2946,7 +2970,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 2946 | 2970 | \\ _ = a << 2; |
| 2947 | 2971 | \\} |
| 2948 | 2972 | , |
| 2949 | ".tmp_source.zig:3:9: error: use of undefined value", | |
| 2973 | ".tmp_source.zig:3:9: error: use of undefined value here causes undefined behavior", | |
| 2950 | 2974 | ); |
| 2951 | 2975 | |
| 2952 | 2976 | cases.add( |
| ... | ... | @@ -2956,7 +2980,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 2956 | 2980 | \\ a <<= 2; |
| 2957 | 2981 | \\} |
| 2958 | 2982 | , |
| 2959 | ".tmp_source.zig:3:5: error: use of undefined value", | |
| 2983 | ".tmp_source.zig:3:5: error: use of undefined value here causes undefined behavior", | |
| 2960 | 2984 | ); |
| 2961 | 2985 | |
| 2962 | 2986 | cases.add( |
| ... | ... | @@ -2966,7 +2990,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 2966 | 2990 | \\ _ = a >> 2; |
| 2967 | 2991 | \\} |
| 2968 | 2992 | , |
| 2969 | ".tmp_source.zig:3:9: error: use of undefined value", | |
| 2993 | ".tmp_source.zig:3:9: error: use of undefined value here causes undefined behavior", | |
| 2970 | 2994 | ); |
| 2971 | 2995 | |
| 2972 | 2996 | cases.add( |
| ... | ... | @@ -2976,7 +3000,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 2976 | 3000 | \\ a >>= 2; |
| 2977 | 3001 | \\} |
| 2978 | 3002 | , |
| 2979 | ".tmp_source.zig:3:5: error: use of undefined value", | |
| 3003 | ".tmp_source.zig:3:5: error: use of undefined value here causes undefined behavior", | |
| 2980 | 3004 | ); |
| 2981 | 3005 | |
| 2982 | 3006 | cases.add( |
| ... | ... | @@ -2986,7 +3010,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 2986 | 3010 | \\ _ = a & a; |
| 2987 | 3011 | \\} |
| 2988 | 3012 | , |
| 2989 | ".tmp_source.zig:3:9: error: use of undefined value", | |
| 3013 | ".tmp_source.zig:3:9: error: use of undefined value here causes undefined behavior", | |
| 2990 | 3014 | ); |
| 2991 | 3015 | |
| 2992 | 3016 | cases.add( |
| ... | ... | @@ -2996,7 +3020,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 2996 | 3020 | \\ a &= a; |
| 2997 | 3021 | \\} |
| 2998 | 3022 | , |
| 2999 | ".tmp_source.zig:3:5: error: use of undefined value", | |
| 3023 | ".tmp_source.zig:3:5: error: use of undefined value here causes undefined behavior", | |
| 3000 | 3024 | ); |
| 3001 | 3025 | |
| 3002 | 3026 | cases.add( |
| ... | ... | @@ -3006,7 +3030,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 3006 | 3030 | \\ _ = a | a; |
| 3007 | 3031 | \\} |
| 3008 | 3032 | , |
| 3009 | ".tmp_source.zig:3:9: error: use of undefined value", | |
| 3033 | ".tmp_source.zig:3:9: error: use of undefined value here causes undefined behavior", | |
| 3010 | 3034 | ); |
| 3011 | 3035 | |
| 3012 | 3036 | cases.add( |
| ... | ... | @@ -3016,7 +3040,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 3016 | 3040 | \\ a |= a; |
| 3017 | 3041 | \\} |
| 3018 | 3042 | , |
| 3019 | ".tmp_source.zig:3:5: error: use of undefined value", | |
| 3043 | ".tmp_source.zig:3:5: error: use of undefined value here causes undefined behavior", | |
| 3020 | 3044 | ); |
| 3021 | 3045 | |
| 3022 | 3046 | cases.add( |
| ... | ... | @@ -3026,7 +3050,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 3026 | 3050 | \\ _ = a ^ a; |
| 3027 | 3051 | \\} |
| 3028 | 3052 | , |
| 3029 | ".tmp_source.zig:3:9: error: use of undefined value", | |
| 3053 | ".tmp_source.zig:3:9: error: use of undefined value here causes undefined behavior", | |
| 3030 | 3054 | ); |
| 3031 | 3055 | |
| 3032 | 3056 | cases.add( |
| ... | ... | @@ -3036,7 +3060,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 3036 | 3060 | \\ a ^= a; |
| 3037 | 3061 | \\} |
| 3038 | 3062 | , |
| 3039 | ".tmp_source.zig:3:5: error: use of undefined value", | |
| 3063 | ".tmp_source.zig:3:5: error: use of undefined value here causes undefined behavior", | |
| 3040 | 3064 | ); |
| 3041 | 3065 | |
| 3042 | 3066 | cases.add( |
| ... | ... | @@ -3046,7 +3070,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 3046 | 3070 | \\ _ = a == a; |
| 3047 | 3071 | \\} |
| 3048 | 3072 | , |
| 3049 | ".tmp_source.zig:3:9: error: use of undefined value", | |
| 3073 | ".tmp_source.zig:3:9: error: use of undefined value here causes undefined behavior", | |
| 3050 | 3074 | ); |
| 3051 | 3075 | |
| 3052 | 3076 | cases.add( |
| ... | ... | @@ -3056,7 +3080,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 3056 | 3080 | \\ _ = a != a; |
| 3057 | 3081 | \\} |
| 3058 | 3082 | , |
| 3059 | ".tmp_source.zig:3:9: error: use of undefined value", | |
| 3083 | ".tmp_source.zig:3:9: error: use of undefined value here causes undefined behavior", | |
| 3060 | 3084 | ); |
| 3061 | 3085 | |
| 3062 | 3086 | cases.add( |
| ... | ... | @@ -3066,7 +3090,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 3066 | 3090 | \\ _ = a > a; |
| 3067 | 3091 | \\} |
| 3068 | 3092 | , |
| 3069 | ".tmp_source.zig:3:9: error: use of undefined value", | |
| 3093 | ".tmp_source.zig:3:9: error: use of undefined value here causes undefined behavior", | |
| 3070 | 3094 | ); |
| 3071 | 3095 | |
| 3072 | 3096 | cases.add( |
| ... | ... | @@ -3076,7 +3100,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 3076 | 3100 | \\ _ = a >= a; |
| 3077 | 3101 | \\} |
| 3078 | 3102 | , |
| 3079 | ".tmp_source.zig:3:9: error: use of undefined value", | |
| 3103 | ".tmp_source.zig:3:9: error: use of undefined value here causes undefined behavior", | |
| 3080 | 3104 | ); |
| 3081 | 3105 | |
| 3082 | 3106 | cases.add( |
| ... | ... | @@ -3086,7 +3110,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 3086 | 3110 | \\ _ = a < a; |
| 3087 | 3111 | \\} |
| 3088 | 3112 | , |
| 3089 | ".tmp_source.zig:3:9: error: use of undefined value", | |
| 3113 | ".tmp_source.zig:3:9: error: use of undefined value here causes undefined behavior", | |
| 3090 | 3114 | ); |
| 3091 | 3115 | |
| 3092 | 3116 | cases.add( |
| ... | ... | @@ -3096,7 +3120,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 3096 | 3120 | \\ _ = a <= a; |
| 3097 | 3121 | \\} |
| 3098 | 3122 | , |
| 3099 | ".tmp_source.zig:3:9: error: use of undefined value", | |
| 3123 | ".tmp_source.zig:3:9: error: use of undefined value here causes undefined behavior", | |
| 3100 | 3124 | ); |
| 3101 | 3125 | |
| 3102 | 3126 | cases.add( |
| ... | ... | @@ -3106,7 +3130,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 3106 | 3130 | \\ _ = a and a; |
| 3107 | 3131 | \\} |
| 3108 | 3132 | , |
| 3109 | ".tmp_source.zig:3:9: error: use of undefined value", | |
| 3133 | ".tmp_source.zig:3:9: error: use of undefined value here causes undefined behavior", | |
| 3110 | 3134 | ); |
| 3111 | 3135 | |
| 3112 | 3136 | cases.add( |
| ... | ... | @@ -3116,7 +3140,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 3116 | 3140 | \\ _ = a or a; |
| 3117 | 3141 | \\} |
| 3118 | 3142 | , |
| 3119 | ".tmp_source.zig:3:9: error: use of undefined value", | |
| 3143 | ".tmp_source.zig:3:9: error: use of undefined value here causes undefined behavior", | |
| 3120 | 3144 | ); |
| 3121 | 3145 | |
| 3122 | 3146 | cases.add( |
| ... | ... | @@ -3126,7 +3150,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 3126 | 3150 | \\ _ = -a; |
| 3127 | 3151 | \\} |
| 3128 | 3152 | , |
| 3129 | ".tmp_source.zig:3:10: error: use of undefined value", | |
| 3153 | ".tmp_source.zig:3:10: error: use of undefined value here causes undefined behavior", | |
| 3130 | 3154 | ); |
| 3131 | 3155 | |
| 3132 | 3156 | cases.add( |
| ... | ... | @@ -3136,7 +3160,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 3136 | 3160 | \\ _ = -%a; |
| 3137 | 3161 | \\} |
| 3138 | 3162 | , |
| 3139 | ".tmp_source.zig:3:11: error: use of undefined value", | |
| 3163 | ".tmp_source.zig:3:11: error: use of undefined value here causes undefined behavior", | |
| 3140 | 3164 | ); |
| 3141 | 3165 | |
| 3142 | 3166 | cases.add( |
| ... | ... | @@ -3146,7 +3170,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 3146 | 3170 | \\ _ = ~a; |
| 3147 | 3171 | \\} |
| 3148 | 3172 | , |
| 3149 | ".tmp_source.zig:3:10: error: use of undefined value", | |
| 3173 | ".tmp_source.zig:3:10: error: use of undefined value here causes undefined behavior", | |
| 3150 | 3174 | ); |
| 3151 | 3175 | |
| 3152 | 3176 | cases.add( |
| ... | ... | @@ -3156,7 +3180,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 3156 | 3180 | \\ _ = !a; |
| 3157 | 3181 | \\} |
| 3158 | 3182 | , |
| 3159 | ".tmp_source.zig:3:10: error: use of undefined value", | |
| 3183 | ".tmp_source.zig:3:10: error: use of undefined value here causes undefined behavior", | |
| 3160 | 3184 | ); |
| 3161 | 3185 | |
| 3162 | 3186 | cases.add( |
| ... | ... | @@ -3166,7 +3190,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 3166 | 3190 | \\ _ = a orelse false; |
| 3167 | 3191 | \\} |
| 3168 | 3192 | , |
| 3169 | ".tmp_source.zig:3:11: error: use of undefined value", | |
| 3193 | ".tmp_source.zig:3:11: error: use of undefined value here causes undefined behavior", | |
| 3170 | 3194 | ); |
| 3171 | 3195 | |
| 3172 | 3196 | cases.add( |
| ... | ... | @@ -3176,7 +3200,7 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 3176 | 3200 | \\ _ = a catch |err| false; |
| 3177 | 3201 | \\} |
| 3178 | 3202 | , |
| 3179 | ".tmp_source.zig:3:11: error: use of undefined value", | |
| 3203 | ".tmp_source.zig:3:11: error: use of undefined value here causes undefined behavior", | |
| 3180 | 3204 | ); |
| 3181 | 3205 | |
| 3182 | 3206 | cases.add( |