From 395ec4239eec2e34e1f6df8323c5657c77db2e98 Mon Sep 17 00:00:00 2001 From: TwoClocks <5883156+TwoClocks@users.noreply.github.com> Date: Tue, 26 Jul 2022 10:20:40 -0700 Subject: [PATCH] Pragma: make pack level nullable --- src/Parser.zig | 2 +- src/pragmas/pack.zig | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Parser.zig b/src/Parser.zig index f8a1bf7c..6f2cbe53 100644 --- a/src/Parser.zig +++ b/src/Parser.zig @@ -161,7 +161,7 @@ record: struct { record_members: std.ArrayListUnmanaged(struct { tok: TokenIndex, name: StringId }) = .{}, @"switch": ?*Switch = null, in_loop: bool = false, -pragma_pack: u8 = 8, +pragma_pack: ?u8 = null, declspec_id: StringId, fn checkIdentifierCodepoint(comp: *Compilation, codepoint: u21, loc: Source.Location) Compilation.Error!bool { diff --git a/src/pragmas/pack.zig b/src/pragmas/pack.zig index 5f857043..4feb1169 100644 --- a/src/pragmas/pack.zig +++ b/src/pragmas/pack.zig @@ -63,7 +63,7 @@ fn parserHandler(pragma: *Pragma, p: *Parser, start_idx: TokenIndex) Compilation try p.pp.comp.diag.add(.{ .tag = .pragma_pack_show, .loc = arg.loc, - .extra = .{ .unsigned = p.pragma_pack }, + .extra = .{ .unsigned = p.pragma_pack orelse 8 }, }, arg.expansionSlice()); }, .push, .pop => { @@ -96,7 +96,7 @@ fn parserHandler(pragma: *Pragma, p: *Parser, start_idx: TokenIndex) Compilation } } if (action == .push) { - try pack.stack.append(p.pp.comp.gpa, .{ .label = label orelse "", .val = p.pragma_pack }); + try pack.stack.append(p.pp.comp.gpa, .{ .label = label orelse "", .val = p.pragma_pack orelse 8 }); } else { pack.pop(p, label); if (new_val != null) { @@ -120,7 +120,7 @@ fn parserHandler(pragma: *Pragma, p: *Parser, start_idx: TokenIndex) Compilation .r_paren => if (apple_or_xl) { pack.pop(p, null); } else { - p.pragma_pack = 8; + p.pragma_pack = null; }, .integer_literal => { idx += 1;