aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-06-09 19:23:36 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-06-09 19:23:36 -0700
commit32c90cb5539c3b340ae1b0b13d2b1521ebb6b1b0 (patch)
tree149e21f6afdce496a95d29d97a1d6e3ccd6d0f4d /src
parentf1cff4fa4a28d42ac9055f94ee9a8f7fd2831cd7 (diff)
downloadzig-32c90cb5539c3b340ae1b0b13d2b1521ebb6b1b0.tar.gz
zig-32c90cb5539c3b340ae1b0b13d2b1521ebb6b1b0.zip
stage2: fix handling of aggregates with mixed comptime-only fields
Diffstat (limited to 'src')
-rw-r--r--src/Sema.zig4
-rw-r--r--src/codegen/llvm.zig6
-rw-r--r--src/type.zig10
3 files changed, 5 insertions, 15 deletions
diff --git a/src/Sema.zig b/src/Sema.zig
index 2d3c38faeb..f1cfd04865 100644
--- a/src/Sema.zig
+++ b/src/Sema.zig
@@ -25048,9 +25048,7 @@ pub fn typeRequiresComptime(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Typ
}
pub fn typeHasRuntimeBits(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) CompileError!bool {
- if ((try sema.typeHasOnePossibleValue(block, src, ty)) != null) return false;
- if (try sema.typeRequiresComptime(block, src, ty)) return false;
- return true;
+ return ty.hasRuntimeBitsAdvanced(false, sema.kit(block, src));
}
fn typeAbiSize(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) !u64 {
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig
index 188c2f6f11..bda81711fb 100644
--- a/src/codegen/llvm.zig
+++ b/src/codegen/llvm.zig
@@ -9185,7 +9185,7 @@ fn isByRef(ty: Type) bool {
.AnyFrame,
=> return false,
- .Array, .Frame => return ty.hasRuntimeBitsIgnoreComptime(),
+ .Array, .Frame => return ty.hasRuntimeBits(),
.Struct => {
// Packed structs are represented to LLVM as integers.
if (ty.containerLayout() == .Packed) return false;
@@ -9204,7 +9204,7 @@ fn isByRef(ty: Type) bool {
var count: usize = 0;
const fields = ty.structFields();
for (fields.values()) |field| {
- if (field.is_comptime or !field.ty.hasRuntimeBitsIgnoreComptime()) continue;
+ if (field.is_comptime or !field.ty.hasRuntimeBits()) continue;
count += 1;
if (count > max_fields_byval) return true;
@@ -9212,7 +9212,7 @@ fn isByRef(ty: Type) bool {
}
return false;
},
- .Union => return ty.hasRuntimeBitsIgnoreComptime(),
+ .Union => return ty.hasRuntimeBits(),
.ErrorUnion => return isByRef(ty.errorUnionPayload()),
.Optional => {
var buf: Type.Payload.ElemType = undefined;
diff --git a/src/type.zig b/src/type.zig
index 9b91572427..049630ef49 100644
--- a/src/type.zig
+++ b/src/type.zig
@@ -2365,6 +2365,7 @@ pub const Type = extern union {
.@"anyframe",
.anyopaque,
.@"opaque",
+ .type_info,
=> return true,
// These are false because they are comptime-only types.
@@ -2379,7 +2380,6 @@ pub const Type = extern union {
.enum_literal,
.empty_struct,
.empty_struct_literal,
- .type_info,
.bound_fn,
// These are function *bodies*, not pointers.
// Special exceptions have to be made when emitting functions due to
@@ -2464,14 +2464,6 @@ pub const Type = extern union {
.@"struct" => {
const struct_obj = ty.castTag(.@"struct").?.data;
- if (sema_kit) |sk| {
- _ = try sk.sema.typeRequiresComptime(sk.block, sk.src, ty);
- }
- switch (struct_obj.requires_comptime) {
- .yes => return false,
- .wip, .no => if (struct_obj.known_non_opv) return true,
- .unknown => {},
- }
if (struct_obj.status == .field_types_wip) {
// In this case, we guess that hasRuntimeBits() for this type is true,
// and then later if our guess was incorrect, we emit a compile error.