Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AstGen: disallow fields and decls from sharing names #21231

Merged
merged 6 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ set(ZIG_STAGE2_SOURCES
src/link/Elf/relocatable.zig
src/link/Elf/relocation.zig
src/link/Elf/synthetic_sections.zig
src/link/Elf/thunks.zig
src/link/Elf/Thunk.zig
src/link/MachO.zig
src/link/MachO/Archive.zig
src/link/MachO/Atom.zig
Expand All @@ -638,7 +638,7 @@ set(ZIG_STAGE2_SOURCES
src/link/MachO/load_commands.zig
src/link/MachO/relocatable.zig
src/link/MachO/synthetic.zig
src/link/MachO/thunks.zig
src/link/MachO/Thunk.zig
src/link/MachO/uuid.zig
src/link/NvPtx.zig
src/link/Plan9.zig
Expand Down
10 changes: 5 additions & 5 deletions lib/std/crypto/poly1305.zig
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub const Poly1305 = struct {
// accumulated hash
h: [3]u64 = [_]u64{ 0, 0, 0 },
// random number added at the end (from the secret key)
pad: [2]u64,
end_pad: [2]u64,
// how many bytes are waiting to be processed in a partial block
leftover: usize = 0,
// partial block buffer
Expand All @@ -24,7 +24,7 @@ pub const Poly1305 = struct {
mem.readInt(u64, key[0..8], .little) & 0x0ffffffc0fffffff,
mem.readInt(u64, key[8..16], .little) & 0x0ffffffc0ffffffc,
},
.pad = [_]u64{
.end_pad = [_]u64{
mem.readInt(u64, key[16..24], .little),
mem.readInt(u64, key[24..32], .little),
},
Expand Down Expand Up @@ -177,9 +177,9 @@ pub const Poly1305 = struct {
h1 ^= mask & (h1 ^ h_p1);

// Add the first half of the key, we intentionally don't use @addWithOverflow() here.
st.h[0] = h0 +% st.pad[0];
const c = ((h0 & st.pad[0]) | ((h0 | st.pad[0]) & ~st.h[0])) >> 63;
st.h[1] = h1 +% st.pad[1] +% c;
st.h[0] = h0 +% st.end_pad[0];
const c = ((h0 & st.end_pad[0]) | ((h0 | st.end_pad[0]) & ~st.h[0])) >> 63;
st.h[1] = h1 +% st.end_pad[1] +% c;

mem.writeInt(u64, out[0..8], st.h[0], .little);
mem.writeInt(u64, out[8..16], st.h[1], .little);
Expand Down
123 changes: 61 additions & 62 deletions lib/std/debug/Pdb.zig

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions lib/std/debug/SelfInfo.zig
Original file line number Diff line number Diff line change
Expand Up @@ -732,14 +732,14 @@ pub const Module = switch (native_os) {
fn getSymbolFromPdb(self: *@This(), relocated_address: usize) !?std.debug.Symbol {
var coff_section: *align(1) const coff.SectionHeader = undefined;
const mod_index = for (self.pdb.?.sect_contribs) |sect_contrib| {
if (sect_contrib.Section > self.coff_section_headers.len) continue;
if (sect_contrib.section > self.coff_section_headers.len) continue;
// Remember that SectionContribEntry.Section is 1-based.
coff_section = &self.coff_section_headers[sect_contrib.Section - 1];
coff_section = &self.coff_section_headers[sect_contrib.section - 1];

const vaddr_start = coff_section.virtual_address + sect_contrib.Offset;
const vaddr_end = vaddr_start + sect_contrib.Size;
const vaddr_start = coff_section.virtual_address + sect_contrib.offset;
const vaddr_end = vaddr_start + sect_contrib.size;
if (relocated_address >= vaddr_start and relocated_address < vaddr_end) {
break sect_contrib.ModuleIndex;
break sect_contrib.module_index;
}
} else {
// we have no information to add to the address
Expand Down
2 changes: 1 addition & 1 deletion lib/std/enums.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1501,7 +1501,7 @@ test values {
X,
Y,
Z,
pub const X = 1;
const A = 1;
};
try testing.expectEqualSlices(E, &.{ .X, .Y, .Z }, values(E));
}
4 changes: 1 addition & 3 deletions lib/std/heap/sbrk_allocator.zig
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@ const assert = std.debug.assert;

pub fn SbrkAllocator(comptime sbrk: *const fn (n: usize) usize) type {
return struct {
pub const vtable = Allocator.VTable{
pub const vtable: Allocator.VTable = .{
.alloc = alloc,
.resize = resize,
.free = free,
};

pub const Error = Allocator.Error;

lock: std.Thread.Mutex = .{},

const max_usize = math.maxInt(usize);
const ushift = math.Log2Int(usize);
const bigpage_size = 64 * 1024;
Expand Down
4 changes: 2 additions & 2 deletions lib/std/meta.zig
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ test declarations {
pub fn a() void {}
};
const U1 = union {
a: u8,
b: u8,

pub fn a() void {}
};
Expand Down Expand Up @@ -334,7 +334,7 @@ test declarationInfo {
pub fn a() void {}
};
const U1 = union {
a: u8,
b: u8,

pub fn a() void {}
};
Expand Down
60 changes: 30 additions & 30 deletions lib/std/os/uefi/device_path.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,38 @@ const uefi = std.os.uefi;
const Guid = uefi.Guid;

pub const DevicePath = union(Type) {
Hardware: Hardware,
Acpi: Acpi,
Messaging: Messaging,
Media: Media,
BiosBootSpecification: BiosBootSpecification,
End: End,
hardware: Hardware,
acpi: Acpi,
messaging: Messaging,
media: Media,
bios_boot_specification: BiosBootSpecification,
end: End,

pub const Type = enum(u8) {
Hardware = 0x01,
Acpi = 0x02,
Messaging = 0x03,
Media = 0x04,
BiosBootSpecification = 0x05,
End = 0x7f,
hardware = 0x01,
acpi = 0x02,
messaging = 0x03,
media = 0x04,
bios_boot_specification = 0x05,
end = 0x7f,
_,
};

pub const Hardware = union(Subtype) {
Pci: *const PciDevicePath,
PcCard: *const PcCardDevicePath,
MemoryMapped: *const MemoryMappedDevicePath,
Vendor: *const VendorDevicePath,
Controller: *const ControllerDevicePath,
Bmc: *const BmcDevicePath,
pci: *const PciDevicePath,
pc_card: *const PcCardDevicePath,
memory_mapped: *const MemoryMappedDevicePath,
vendor: *const VendorDevicePath,
controller: *const ControllerDevicePath,
bmc: *const BmcDevicePath,

pub const Subtype = enum(u8) {
Pci = 1,
PcCard = 2,
MemoryMapped = 3,
Vendor = 4,
Controller = 5,
Bmc = 6,
pci = 1,
pc_card = 2,
memory_mapped = 3,
vendor = 4,
controller = 5,
bmc = 6,
_,
};

Expand Down Expand Up @@ -151,14 +151,14 @@ pub const DevicePath = union(Type) {
};

pub const Acpi = union(Subtype) {
Acpi: *const BaseAcpiDevicePath,
ExpandedAcpi: *const ExpandedAcpiDevicePath,
Adr: *const AdrDevicePath,
acpi: *const BaseAcpiDevicePath,
expanded_acpi: *const ExpandedAcpiDevicePath,
adr: *const AdrDevicePath,

pub const Subtype = enum(u8) {
Acpi = 1,
ExpandedAcpi = 2,
Adr = 3,
acpi = 1,
expanded_acpi = 2,
adr = 3,
_,
};

Expand Down
Loading