Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
accd570
compiler: move struct types into InternPool proper
andrewrk Aug 25, 2023
fa1beba
InternPool: implement getStructType
andrewrk Sep 20, 2023
b65f3d8
InternPool: implement extraStructType
andrewrk Sep 20, 2023
483b3a3
InternPool: implement only_possible_value prong of indexToKey
andrewrk Sep 20, 2023
baea62a
fix regressions from this branch
andrewrk Sep 20, 2023
f739ac9
sema: delete dead code
andrewrk Sep 20, 2023
2da62a7
Sema: restore master branch field reordering behavior
andrewrk Sep 20, 2023
0182b72
TypedValue: do not crash when failing to dereference pointer
mlugg Sep 20, 2023
ada83fa
compiler: get codegen of behavior tests working on at least one backend
mlugg Sep 20, 2023
c79da0d
Sema: allow users to provide alignment 0 to mean default
andrewrk Sep 20, 2023
2671aa9
InternPool: fix nameIndex for tuples
andrewrk Sep 20, 2023
5ea3de5
Sema: fix dependency loop regression on struct field alignment
andrewrk Sep 20, 2023
51b1a2a
Alignment: min/minStrict max/maxStrict
andrewrk Sep 21, 2023
d06bf70
compiler: make pointer type canonicalization always work
andrewrk Sep 21, 2023
dca17d3
Sema: fix struct alignment regressions
andrewrk Sep 21, 2023
7d9cf15
TypedValue: fix crash for tuples when printing
andrewrk Sep 21, 2023
cd242b7
Sema: queue type resolution when adding a struct_field_val instruction
andrewrk Sep 21, 2023
1b672e4
InternPool,Sema,type,llvm: alignment fixes
mlugg Sep 21, 2023
d3f3de7
Sema: less aggressive type resolution for field_val
andrewrk Sep 21, 2023
9965d96
type: give empty unions 1-byte alignment
mlugg Sep 21, 2023
2e5d13e
Sema: queue type resolution when analyzing ret_ptr during inline call
mlugg Sep 21, 2023
55bc8a7
compiler: fix compilation for 32-bit targets
andrewrk Sep 21, 2023
edfada4
Sema: mark transitive failure when @import refers to a failed file
mlugg Sep 21, 2023
81b5df3
compiler: fix structFieldName crash for tuples
andrewrk Sep 22, 2023
7474406
LLVM: fix UAF when lowering debug info for structs
andrewrk Sep 22, 2023
221295b
wasm: fix regression of C ABI
andrewrk Sep 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 24 additions & 7 deletions src/AstGen.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4758,6 +4758,9 @@ fn structDeclInner(
.known_non_opv = false,
.known_comptime_only = false,
.is_tuple = false,
.any_comptime_fields = false,
.any_default_inits = false,
.any_aligned_fields = false,
});
return indexToRef(decl_inst);
}
Expand Down Expand Up @@ -4881,6 +4884,9 @@ fn structDeclInner(

var known_non_opv = false;
var known_comptime_only = false;
var any_comptime_fields = false;
var any_aligned_fields = false;
var any_default_inits = false;
for (container_decl.ast.members) |member_node| {
var member = switch (try containerMember(&block_scope, &namespace.base, &wip_members, member_node)) {
.decl => continue,
Expand Down Expand Up @@ -4910,13 +4916,13 @@ fn structDeclInner(
const have_value = member.ast.value_expr != 0;
const is_comptime = member.comptime_token != null;

if (is_comptime and layout == .Packed) {
return astgen.failTok(member.comptime_token.?, "packed struct fields cannot be marked comptime", .{});
} else if (is_comptime and layout == .Extern) {
return astgen.failTok(member.comptime_token.?, "extern struct fields cannot be marked comptime", .{});
}

if (!is_comptime) {
if (is_comptime) {
switch (layout) {
.Packed => return astgen.failTok(member.comptime_token.?, "packed struct fields cannot be marked comptime", .{}),
.Extern => return astgen.failTok(member.comptime_token.?, "extern struct fields cannot be marked comptime", .{}),
.Auto => any_comptime_fields = true,
}
} else {
known_non_opv = known_non_opv or
nodeImpliesMoreThanOnePossibleValue(tree, member.ast.type_expr);
known_comptime_only = known_comptime_only or
Expand All @@ -4942,6 +4948,7 @@ fn structDeclInner(
if (layout == .Packed) {
try astgen.appendErrorNode(member.ast.align_expr, "unable to override alignment of packed struct fields", .{});
}
any_aligned_fields = true;
const align_ref = try expr(&block_scope, &namespace.base, coerced_align_ri, member.ast.align_expr);
if (!block_scope.endsWithNoReturn()) {
_ = try block_scope.addBreak(.break_inline, decl_inst, align_ref);
Expand All @@ -4955,6 +4962,7 @@ fn structDeclInner(
}

if (have_value) {
any_default_inits = true;
const ri: ResultInfo = .{ .rl = if (field_type == .none) .none else .{ .coerced_ty = field_type } };

const default_inst = try expr(&block_scope, &namespace.base, ri, member.ast.value_expr);
Expand Down Expand Up @@ -4982,6 +4990,9 @@ fn structDeclInner(
.known_non_opv = known_non_opv,
.known_comptime_only = known_comptime_only,
.is_tuple = is_tuple,
.any_comptime_fields = any_comptime_fields,
.any_default_inits = any_default_inits,
.any_aligned_fields = any_aligned_fields,
});

wip_members.finishBits(bits_per_field);
Expand Down Expand Up @@ -12080,6 +12091,9 @@ const GenZir = struct {
known_non_opv: bool,
known_comptime_only: bool,
is_tuple: bool,
any_comptime_fields: bool,
any_default_inits: bool,
any_aligned_fields: bool,
}) !void {
const astgen = gz.astgen;
const gpa = astgen.gpa;
Expand Down Expand Up @@ -12117,6 +12131,9 @@ const GenZir = struct {
.is_tuple = args.is_tuple,
.name_strategy = gz.anon_name_strategy,
.layout = args.layout,
.any_comptime_fields = args.any_comptime_fields,
.any_default_inits = args.any_default_inits,
.any_aligned_fields = args.any_aligned_fields,
}),
.operand = payload_index,
} },
Expand Down
Loading