std: fix compile errors caught by stage2 AstGen

Follow-up from 507a8096d2
This commit is contained in:
Andrew Kelley
2021-04-22 19:32:57 -07:00
parent 8dd7378013
commit 93d1c2d6d4
17 changed files with 38 additions and 36 deletions

View File

@@ -121,7 +121,7 @@ pub const AI_NUMERICHOST = 0x00000004;
/// prevent service name resolution
pub const AI_NUMERICSERV = 0x00001000;
pub const EAI = extern enum(c_int) {
pub const EAI = enum(c_int) {
/// address family for hostname not supported
ADDRFAMILY = 1,

View File

@@ -62,7 +62,7 @@ pub const sem_t = extern struct {
_padding: u32,
};
pub const EAI = extern enum(c_int) {
pub const EAI = enum(c_int) {
/// address family for hostname not supported
ADDRFAMILY = 1,

View File

@@ -39,7 +39,7 @@ pub const NI_NAMEREQD = 0x08;
pub const NI_DGRAM = 0x10;
pub const NI_NUMERICSCOPE = 0x100;
pub const EAI = extern enum(c_int) {
pub const EAI = enum(c_int) {
BADFLAGS = -1,
NONAME = -2,
AGAIN = -3,

View File

@@ -98,7 +98,7 @@ pub const Curve25519 = struct {
/// key is a low-order point.
pub fn mul(p: Curve25519, s: [32]u8) Error!Curve25519 {
const cofactor = [_]u8{8} ++ [_]u8{0} ** 31;
_ = ladder(p, cofactor, 4) catch |_| return error.WeakPublicKey;
_ = ladder(p, cofactor, 4) catch return error.WeakPublicKey;
return try ladder(p, s, 256);
}

View File

@@ -900,7 +900,7 @@ pub fn formatBuf(
) !void {
if (options.width) |min_width| {
// In case of error assume the buffer content is ASCII-encoded
const width = unicode.utf8CountCodepoints(buf) catch |_| buf.len;
const width = unicode.utf8CountCodepoints(buf) catch buf.len;
const padding = if (width < min_width) min_width - width else 0;
if (padding == 0)

View File

@@ -854,7 +854,7 @@ test "opcodes" {
expect_opcode(0x95, Insn.exit());
}
pub const Cmd = extern enum(usize) {
pub const Cmd = enum(usize) {
/// Create a map and return a file descriptor that refers to the map. The
/// close-on-exec file descriptor flag is automatically enabled for the new
/// file descriptor.
@@ -977,7 +977,7 @@ pub const Cmd = extern enum(usize) {
_,
};
pub const MapType = extern enum(u32) {
pub const MapType = enum(u32) {
unspec,
hash,
array,
@@ -1044,7 +1044,7 @@ pub const MapType = extern enum(u32) {
_,
};
pub const ProgType = extern enum(u32) {
pub const ProgType = enum(u32) {
unspec,
/// context type: __sk_buff
@@ -1139,7 +1139,7 @@ pub const ProgType = extern enum(u32) {
_,
};
pub const AttachType = extern enum(u32) {
pub const AttachType = enum(u32) {
cgroup_inet_ingress,
cgroup_inet_egress,
cgroup_inet_sock_create,

View File

@@ -90,7 +90,7 @@ pub const DevicePath = union(DevicePathType) {
End: EndDevicePath,
};
pub const DevicePathType = extern enum(u8) {
pub const DevicePathType = enum(u8) {
Hardware = 0x01,
Acpi = 0x02,
Messaging = 0x03,
@@ -108,7 +108,7 @@ pub const HardwareDevicePath = union(Subtype) {
Controller: *const ControllerDevicePath,
Bmc: *const BmcDevicePath,
pub const Subtype = extern enum(u8) {
pub const Subtype = enum(u8) {
Pci = 1,
PcCard = 2,
MemoryMapped = 3,
@@ -167,7 +167,7 @@ pub const AcpiDevicePath = union(Subtype) {
Adr: void, // TODO
Nvdimm: void, // TODO
pub const Subtype = extern enum(u8) {
pub const Subtype = enum(u8) {
Acpi = 1,
ExpandedAcpi = 2,
Adr = 3,
@@ -196,7 +196,7 @@ pub const MessagingDevicePath = union(Subtype) {
Uart: void, // TODO
Vendor: void, // TODO
pub const Subtype = extern enum(u8) {
pub const Subtype = enum(u8) {
Atapi = 1,
Scsi = 2,
FibreChannel = 3,
@@ -230,7 +230,7 @@ pub const MediaDevicePath = union(Subtype) {
RelativeOffsetRange: *const RelativeOffsetRangeDevicePath,
RamDisk: *const RamDiskDevicePath,
pub const Subtype = extern enum(u8) {
pub const Subtype = enum(u8) {
HardDrive = 1,
Cdrom = 2,
Vendor = 3,
@@ -316,7 +316,7 @@ pub const MediaDevicePath = union(Subtype) {
pub const BiosBootSpecificationDevicePath = union(Subtype) {
BBS101: *const BBS101DevicePath,
pub const Subtype = extern enum(u8) {
pub const Subtype = enum(u8) {
BBS101 = 1,
_,
};
@@ -338,7 +338,7 @@ pub const EndDevicePath = union(Subtype) {
EndEntire: *const EndEntireDevicePath,
EndThisInstance: *const EndThisInstanceDevicePath,
pub const Subtype = extern enum(u8) {
pub const Subtype = enum(u8) {
EndEntire = 0xff,
EndThisInstance = 0x01,
_,

View File

@@ -57,7 +57,7 @@ pub const GraphicsOutputModeInformation = extern struct {
pixels_per_scan_line: u32 = undefined,
};
pub const GraphicsPixelFormat = extern enum(u32) {
pub const GraphicsPixelFormat = enum(u32) {
PixelRedGreenBlueReserved8BitPerColor,
PixelBlueGreenRedReserved8BitPerColor,
PixelBitMask,
@@ -79,7 +79,7 @@ pub const GraphicsOutputBltPixel = extern struct {
reserved: u8 = undefined,
};
pub const GraphicsOutputBltOperation = extern enum(u32) {
pub const GraphicsOutputBltOperation = enum(u32) {
BltVideoFill,
BltVideoToBltBuffer,
BltBufferToVideo,

View File

@@ -28,20 +28,20 @@ pub const HIIPopupProtocol = extern struct {
};
};
pub const HIIPopupStyle = extern enum(u32) {
pub const HIIPopupStyle = enum(u32) {
Info,
Warning,
Error,
};
pub const HIIPopupType = extern enum(u32) {
pub const HIIPopupType = enum(u32) {
Ok,
Cancel,
YesNo,
YesNoCancel,
};
pub const HIIPopupSelection = extern enum(u32) {
pub const HIIPopupSelection = enum(u32) {
Ok,
Cancel,
Yes,

View File

@@ -40,7 +40,7 @@ pub const Ip6ConfigProtocol = extern struct {
};
};
pub const Ip6ConfigDataType = extern enum(u32) {
pub const Ip6ConfigDataType = enum(u32) {
InterfaceInfo,
AltInterfaceId,
Policy,

View File

@@ -123,7 +123,7 @@ pub const Ip6RouteTable = extern struct {
prefix_length: u8,
};
pub const Ip6NeighborState = extern enum(u32) {
pub const Ip6NeighborState = enum(u32) {
Incomplete,
Reachable,
Stale,

View File

@@ -134,7 +134,7 @@ pub const SimpleNetworkReceiveFilter = packed struct {
_pad: u27 = undefined,
};
pub const SimpleNetworkState = extern enum(u32) {
pub const SimpleNetworkState = enum(u32) {
Stopped,
Started,
Initialized,

View File

@@ -156,13 +156,13 @@ pub const BootServices = extern struct {
pub const tpl_high_level: usize = 31;
};
pub const TimerDelay = extern enum(u32) {
pub const TimerDelay = enum(u32) {
TimerCancel,
TimerPeriodic,
TimerRelative,
};
pub const MemoryType = extern enum(u32) {
pub const MemoryType = enum(u32) {
ReservedMemoryType,
LoaderCode,
LoaderData,
@@ -206,7 +206,7 @@ pub const MemoryDescriptor = extern struct {
},
};
pub const LocateSearchType = extern enum(u32) {
pub const LocateSearchType = enum(u32) {
AllHandles,
ByRegisterNotify,
ByProtocol,
@@ -229,7 +229,7 @@ pub const ProtocolInformationEntry = extern struct {
open_count: u32,
};
pub const AllocateType = extern enum(u32) {
pub const AllocateType = enum(u32) {
AllocateAnyPages,
AllocateMaxAddress,
AllocateAddress,

View File

@@ -51,7 +51,7 @@ pub const RuntimeServices = extern struct {
pub const signature: u64 = 0x56524553544e5552;
};
pub const ResetType = extern enum(u32) {
pub const ResetType = enum(u32) {
ResetCold,
ResetWarm,
ResetShutdown,

View File

@@ -10,18 +10,20 @@
const std = @import("std");
const builtin = @import("builtin");
const LE = extern enum(i32) {
const LE = enum(i32) {
Less = -1,
Equal = 0,
Greater = 1,
Unordered = 1,
const Unordered: LE = .Greater;
};
const GE = extern enum(i32) {
const GE = enum(i32) {
Less = -1,
Equal = 0,
Greater = 1,
Unordered = -1,
const Unordered: GE = .Less;
};
pub fn cmp(comptime T: type, comptime RT: type, a: T, b: T) RT {
@@ -43,7 +45,7 @@ pub fn cmp(comptime T: type, comptime RT: type, a: T, b: T) RT {
const bAbs = @bitCast(rep_t, bInt) & absMask;
// If either a or b is NaN, they are unordered.
if (aAbs > infRep or bAbs > infRep) return .Unordered;
if (aAbs > infRep or bAbs > infRep) return RT.Unordered;
// If a and b are both zeros, they are equal.
if ((aAbs | bAbs) == 0) return .Equal;

View File

@@ -11,7 +11,7 @@ const builtin = @import("builtin");
// The SPARC Architecture Manual, Version 9:
// A.13 Floating-Point Compare
const FCMP = extern enum(i32) {
const FCMP = enum(i32) {
Equal = 0,
Less = 1,
Greater = 2,

View File

@@ -506,7 +506,7 @@ pub const list = list: {
"@intToFloat",
.{
.tag = .int_to_float,
.param_count = 1,
.param_count = 2,
},
},
.{