Sema: additional check for one-possible-value types in analyzeLoad
This is needed because pointers to zero-bit types are not necessarily comptime known, but when doing a load, only the element type having one possible value is relevant.
This commit is contained in:
@@ -20950,6 +20950,11 @@ fn analyzeLoad(
|
||||
.Pointer => ptr_ty.childType(),
|
||||
else => return sema.fail(block, ptr_src, "expected pointer, found '{}'", .{ptr_ty.fmt(sema.mod)}),
|
||||
};
|
||||
|
||||
if (try sema.typeHasOnePossibleValue(block, src, elem_ty)) |opv| {
|
||||
return sema.addConstant(elem_ty, opv);
|
||||
}
|
||||
|
||||
if (try sema.resolveDefinedValue(block, ptr_src, ptr)) |ptr_val| {
|
||||
if (try sema.pointerDeref(block, ptr_src, ptr_val, ptr_ty)) |elem_val| {
|
||||
return sema.addConstant(elem_ty, elem_val);
|
||||
|
||||
Reference in New Issue
Block a user