Commit 93d1c2d6d4

Andrew Kelley <andrew@ziglang.org>
2021-04-23 04:32:57
std: fix compile errors caught by stage2 AstGen
Follow-up from 507a8096d2f9624bafaf963c3e189a477ef6b7bf
1 parent 8dd7378
lib/std/c/darwin.zig
@@ -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,
 
lib/std/c/freebsd.zig
@@ -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,
 
lib/std/c/linux.zig
@@ -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,
lib/std/crypto/25519/curve25519.zig
@@ -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);
     }
 
lib/std/os/linux/bpf.zig
@@ -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,
lib/std/os/uefi/protocols/device_path_protocol.zig
@@ -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,
         _,
lib/std/os/uefi/protocols/graphics_output_protocol.zig
@@ -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,
lib/std/os/uefi/protocols/hii_popup_protocol.zig
@@ -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,
lib/std/os/uefi/protocols/ip6_config_protocol.zig
@@ -40,7 +40,7 @@ pub const Ip6ConfigProtocol = extern struct {
     };
 };
 
-pub const Ip6ConfigDataType = extern enum(u32) {
+pub const Ip6ConfigDataType = enum(u32) {
     InterfaceInfo,
     AltInterfaceId,
     Policy,
lib/std/os/uefi/protocols/ip6_protocol.zig
@@ -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,
lib/std/os/uefi/protocols/simple_network_protocol.zig
@@ -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,
lib/std/os/uefi/tables/boot_services.zig
@@ -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,
lib/std/os/uefi/tables/runtime_services.zig
@@ -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,
lib/std/special/compiler_rt/compareXf2.zig
@@ -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;
lib/std/special/compiler_rt/sparc.zig
@@ -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,
lib/std/fmt.zig
@@ -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)
src/BuiltinFn.zig
@@ -506,7 +506,7 @@ pub const list = list: {
             "@intToFloat",
             .{
                 .tag = .int_to_float,
-                .param_count = 1,
+                .param_count = 2,
             },
         },
         .{