Skip to content

Commit 0c76561

Browse files
Merge branch 'master' into feature/hash-package-command
2 parents 1af3a9e + ff59c45 commit 0c76561

File tree

10 files changed

+137
-14
lines changed

10 files changed

+137
-14
lines changed

lib/std/c/darwin.zig

+86
Original file line numberDiff line numberDiff line change
@@ -3916,3 +3916,89 @@ pub const THREAD_AFFINITY = struct {
39163916
/// individual cpus (high performance cpus group and low consumption one), thus the pthread QOS api is more appropriate in this case.
39173917
pub extern "c" fn thread_affinity_get(thread: thread_act_t, flavor: thread_policy_flavor_t, info: thread_policy_t, infocnt: [*]mach_msg_type_number_t, default: *boolean_t) kern_return_t;
39183918
pub extern "c" fn thread_affinity_set(thread: thread_act_t, flavor: thread_policy_flavor_t, info: thread_policy_t, infocnt: mach_msg_type_number_t) kern_return_t;
3919+
3920+
pub const cpu_type_t = integer_t;
3921+
pub const cpu_subtype_t = integer_t;
3922+
pub const cpu_threadtype_t = integer_t;
3923+
pub const host_flavor_t = integer_t;
3924+
pub const host_info_t = *integer_t;
3925+
pub const host_can_has_debugger_info = extern struct {
3926+
can_has_debugger: boolean_t,
3927+
};
3928+
pub const host_can_has_debugger_info_data_t = host_can_has_debugger_info;
3929+
pub const host_can_has_debugger_info_t = *host_can_has_debugger_info;
3930+
3931+
pub const host_sched_info = extern struct {
3932+
min_timeout: integer_t,
3933+
min_quantum: integer_t,
3934+
};
3935+
pub const host_sched_info_data_t = host_sched_info;
3936+
pub const host_sched_info_t = *host_sched_info;
3937+
3938+
pub const kernel_resource_sizes = extern struct {
3939+
task: natural_t,
3940+
thread: natural_t,
3941+
port: natural_t,
3942+
memory_region: natural_t,
3943+
memory_object: natural_t,
3944+
};
3945+
3946+
pub const kernel_resource_sizes_data_t = kernel_resource_sizes;
3947+
pub const kernel_resource_sizes_t = *kernel_resource_sizes;
3948+
3949+
pub const host_priority_info = extern struct {
3950+
kernel_priority: integer_t,
3951+
system_priority: integer_t,
3952+
server_priority: integer_t,
3953+
user_priority: integer_t,
3954+
depress_priority: integer_t,
3955+
idle_priority: integer_t,
3956+
minimum_priority: integer_t,
3957+
maximum_priority: integer_t,
3958+
};
3959+
3960+
pub const host_priority_info_data_t = host_priority_info;
3961+
pub const host_priority_info_t = *host_priority_info;
3962+
3963+
pub const CPU_STATE_MAX = 4;
3964+
3965+
pub const host_cpu_load_info = extern struct {
3966+
cpu_ticks: [CPU_STATE_MAX]natural_t,
3967+
};
3968+
3969+
pub const host_cpu_load_info_data_t = host_cpu_load_info;
3970+
pub const host_cpu_load_info_t = *host_cpu_load_info;
3971+
3972+
pub const HOST = struct {
3973+
pub const BASIC_INFO = 1;
3974+
pub const SCHED_INFO = 3;
3975+
pub const RESOURCE_SIZES = 4;
3976+
pub const PRIORITY_INFO = 5;
3977+
pub const SEMAPHORE_TRAPS = 7;
3978+
pub const MACH_MSG_TRAPS = 8;
3979+
pub const VM_PURGEABLE = 9;
3980+
pub const DEBUG_INFO_INTERNAL = 10;
3981+
pub const CAN_HAS_DEBUGGER = 11;
3982+
pub const PREFERRED_USER_ARCH = 12;
3983+
pub const CAN_HAS_DEBUGGER_COUNT = @intCast(mach_msg_type_number_t, @sizeOf(host_can_has_debugger_info_data_t) / @sizeOf(integer_t));
3984+
pub const SCHED_INFO_COUNT = @intCast(mach_msg_type_number_t, @sizeOf(host_sched_info_data_t) / @sizeOf(integer_t));
3985+
pub const RESOURCES_SIZES_COUNT = @intCast(mach_msg_type_number_t, @sizeOf(kernel_resource_sizes_data_t) / @sizeOf(integer_t));
3986+
pub const PRIORITY_INFO_COUNT = @intCast(mach_msg_type_number_t, @sizeOf(host_priority_info_data_t) / @sizeOf(integer_t));
3987+
pub const CPU_LOAD_INFO_COUNT = @intCast(mach_msg_type_number_t, @sizeOf(host_cpu_load_info_data_t) / @sizeOf(integer_t));
3988+
};
3989+
3990+
pub const host_basic_info = packed struct(u32) {
3991+
max_cpus: integer_t,
3992+
avail_cpus: integer_t,
3993+
memory_size: natural_t,
3994+
cpu_type: cpu_type_t,
3995+
cpu_subtype: cpu_subtype_t,
3996+
cpu_threadtype: cpu_threadtype_t,
3997+
physical_cpu: integer_t,
3998+
physical_cpu_max: integer_t,
3999+
logical_cpu: integer_t,
4000+
logical_cpu_max: integer_t,
4001+
max_mem: u64,
4002+
};
4003+
4004+
pub extern "c" fn host_info(host: host_t, flavor: host_flavor_t, info_out: host_info_t, info_outCnt: [*]mach_msg_type_number_t) kern_return_t;

lib/std/elf.zig

+7
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,14 @@ pub const SHT_GROUP = 17;
296296
pub const SHT_SYMTAB_SHNDX = 18;
297297
/// Start of OS-specific
298298
pub const SHT_LOOS = 0x60000000;
299+
/// LLVM address-significance table
300+
pub const SHT_LLVM_ADDRSIG = 0x6fff4c03;
299301
/// End of OS-specific
300302
pub const SHT_HIOS = 0x6fffffff;
301303
/// Start of processor-specific
302304
pub const SHT_LOPROC = 0x70000000;
305+
/// Unwind information
306+
pub const SHT_X86_64_UNWIND = 0x70000001;
303307
/// End of processor-specific
304308
pub const SHT_HIPROC = 0x7fffffff;
305309
/// Start of application-specific
@@ -1632,6 +1636,9 @@ pub const SHF_TLS = 0x400;
16321636
/// Identifies a section containing compressed data.
16331637
pub const SHF_COMPRESSED = 0x800;
16341638

1639+
/// Not to be GCed by the linker
1640+
pub const SHF_GNU_RETAIN = 0x200000;
1641+
16351642
/// This section is excluded from the final executable or shared library.
16361643
pub const SHF_EXCLUDE = 0x80000000;
16371644

lib/std/zig/number_literal.zig

+3-7
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ pub const Error = union(enum) {
4444
duplicate_period,
4545
/// Float literal has multiple exponents.
4646
duplicate_exponent: usize,
47-
/// Decimal float has hexadecimal exponent.
48-
invalid_hex_exponent: usize,
4947
/// Exponent comes directly after '_' digit separator.
5048
exponent_after_underscore: usize,
5149
/// Special character (+-.) comes directly after exponent.
@@ -103,7 +101,6 @@ pub fn parseNumberLiteral(bytes: []const u8) Result {
103101
},
104102
'e', 'E' => if (base == 10) {
105103
float = true;
106-
if (base != 10 and base != 16) return .{ .failure = .{ .invalid_float_base = 2 } };
107104
if (exponent) return .{ .failure = .{ .duplicate_exponent = i } };
108105
if (underscore) return .{ .failure = .{ .exponent_after_underscore = i } };
109106
special = c;
@@ -112,26 +109,25 @@ pub fn parseNumberLiteral(bytes: []const u8) Result {
112109
},
113110
'p', 'P' => if (base == 16) {
114111
float = true;
115-
if (base != 10 and base != 16) return .{ .failure = .{ .invalid_float_base = 2 } };
116112
if (exponent) return .{ .failure = .{ .duplicate_exponent = i } };
117113
if (underscore) return .{ .failure = .{ .exponent_after_underscore = i } };
118-
if (base != 16) return .{ .failure = .{ .invalid_hex_exponent = i } };
119114
special = c;
120115
exponent = true;
121116
continue;
122117
},
123118
'.' => {
124119
float = true;
125120
if (base != 10 and base != 16) return .{ .failure = .{ .invalid_float_base = 2 } };
126-
if (period) return .{ .failure = .{ .duplicate_exponent = i } };
121+
if (period) return .{ .failure = .duplicate_period };
127122
period = true;
128123
if (underscore) return .{ .failure = .{ .special_after_underscore = i } };
129124
special = c;
130125
continue;
131126
},
132127
'+', '-' => {
133128
switch (special) {
134-
'p', 'P', 'e', 'E' => {},
129+
'p', 'P' => {},
130+
'e', 'E' => if (base != 10) return .{ .failure = .{ .invalid_exponent_sign = i } },
135131
else => return .{ .failure = .{ .invalid_exponent_sign = i } },
136132
}
137133
special = c;

src/AstGen.zig

+13-3
Original file line numberDiff line numberDiff line change
@@ -2905,7 +2905,15 @@ fn deferStmt(
29052905
const sub_scope = if (!have_err_code) &defer_gen.base else blk: {
29062906
try gz.addDbgBlockBegin();
29072907
const ident_name = try gz.astgen.identAsString(payload_token);
2908-
remapped_err_code = @intCast(u32, try gz.astgen.instructions.addOne(gz.astgen.gpa));
2908+
remapped_err_code = @intCast(Zir.Inst.Index, gz.astgen.instructions.len);
2909+
try gz.astgen.instructions.append(gz.astgen.gpa, .{
2910+
.tag = .extended,
2911+
.data = .{ .extended = .{
2912+
.opcode = .errdefer_err_code,
2913+
.small = undefined,
2914+
.operand = undefined,
2915+
} },
2916+
});
29092917
const remapped_err_code_ref = Zir.indexToRef(remapped_err_code);
29102918
local_val_scope = .{
29112919
.parent = &defer_gen.base,
@@ -7614,14 +7622,16 @@ fn failWithNumberError(astgen: *AstGen, err: std.zig.number_literal.Error, token
76147622
.invalid_digit => |info| return astgen.failOff(token, @intCast(u32, info.i), "invalid digit '{c}' for {s} base", .{ bytes[info.i], @tagName(info.base) }),
76157623
.invalid_digit_exponent => |i| return astgen.failOff(token, @intCast(u32, i), "invalid digit '{c}' in exponent", .{bytes[i]}),
76167624
.duplicate_exponent => |i| return astgen.failOff(token, @intCast(u32, i), "duplicate exponent", .{}),
7617-
.invalid_hex_exponent => |i| return astgen.failOff(token, @intCast(u32, i), "hex exponent in decimal float", .{}),
76187625
.exponent_after_underscore => |i| return astgen.failOff(token, @intCast(u32, i), "expected digit before exponent", .{}),
76197626
.special_after_underscore => |i| return astgen.failOff(token, @intCast(u32, i), "expected digit before '{c}'", .{bytes[i]}),
76207627
.trailing_special => |i| return astgen.failOff(token, @intCast(u32, i), "expected digit after '{c}'", .{bytes[i - 1]}),
76217628
.trailing_underscore => |i| return astgen.failOff(token, @intCast(u32, i), "trailing digit separator", .{}),
76227629
.duplicate_period => unreachable, // Validated by tokenizer
76237630
.invalid_character => unreachable, // Validated by tokenizer
7624-
.invalid_exponent_sign => unreachable, // Validated by tokenizer
7631+
.invalid_exponent_sign => |i| {
7632+
assert(bytes.len >= 2 and bytes[0] == '0' and bytes[1] == 'x'); // Validated by tokenizer
7633+
return astgen.failOff(token, @intCast(u32, i), "sign '{c}' cannot follow digit '{c}' in hex base", .{ bytes[i], bytes[i - 1] });
7634+
},
76257635
}
76267636
}
76277637

src/Autodoc.zig

+6
Original file line numberDiff line numberDiff line change
@@ -996,6 +996,12 @@ fn walkInstruction(
996996
};
997997
}
998998

999+
const maybe_tldoc_comment = try self.getTLDocComment(new_file.file);
1000+
try self.ast_nodes.append(self.arena, .{
1001+
.name = path,
1002+
.docs = maybe_tldoc_comment,
1003+
});
1004+
9991005
result.value_ptr.* = self.types.items.len;
10001006

10011007
var new_scope = Scope{

src/Sema.zig

+1
Original file line numberDiff line numberDiff line change
@@ -1198,6 +1198,7 @@ fn analyzeBodyInner(
11981198
i += 1;
11991199
continue;
12001200
},
1201+
.errdefer_err_code => unreachable, // never appears in a body
12011202
};
12021203
},
12031204

src/Zir.zig

+5-2
Original file line numberDiff line numberDiff line change
@@ -1979,7 +1979,7 @@ pub const Inst = struct {
19791979
/// `operand` is `src_node: i32`.
19801980
breakpoint,
19811981
/// Implements the `@select` builtin.
1982-
/// operand` is payload index to `Select`.
1982+
/// `operand` is payload index to `Select`.
19831983
select,
19841984
/// Implement builtin `@errToInt`.
19851985
/// `operand` is payload index to `UnNode`.
@@ -1999,7 +1999,7 @@ pub const Inst = struct {
19991999
/// `operand` is payload index to `Cmpxchg`.
20002000
cmpxchg,
20012001
/// Implement the builtin `@addrSpaceCast`
2002-
/// `Operand` is payload index to `BinNode`. `lhs` is dest type, `rhs` is operand.
2002+
/// `operand` is payload index to `BinNode`. `lhs` is dest type, `rhs` is operand.
20032003
addrspace_cast,
20042004
/// Implement builtin `@cVaArg`.
20052005
/// `operand` is payload index to `BinNode`.
@@ -2031,6 +2031,9 @@ pub const Inst = struct {
20312031
/// Implements the `@inComptime` builtin.
20322032
/// `operand` is `src_node: i32`.
20332033
in_comptime,
2034+
/// Used as a placeholder for the capture of an `errdefer`.
2035+
/// This is replaced by Sema with the captured value.
2036+
errdefer_err_code,
20342037

20352038
pub const InstData = struct {
20362039
opcode: Extended,

src/codegen/c.zig

+2-2
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ const reserved_idents = std.ComptimeStringMap(void, .{
159159
.{ "double", {} },
160160
.{ "else", {} },
161161
.{ "enum", {} },
162-
.{ "extern ", {} },
162+
.{ "extern", {} },
163163
.{ "float", {} },
164164
.{ "for", {} },
165165
.{ "fortran", {} },
@@ -198,7 +198,7 @@ const reserved_idents = std.ComptimeStringMap(void, .{
198198
.{ "unsigned", {} },
199199
.{ "void", {} },
200200
.{ "volatile", {} },
201-
.{ "while ", {} },
201+
.{ "while", {} },
202202

203203
// stdarg.h
204204
.{ "va_start", {} },

src/print_zir.zig

+1
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,7 @@ const Writer = struct {
467467
.breakpoint,
468468
.c_va_start,
469469
.in_comptime,
470+
.errdefer_err_code,
470471
=> try self.writeExtNode(stream, extended),
471472

472473
.builtin_src => {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const a = 0x1e-4;
2+
const b = 0x1e+4;
3+
const c = 0x1E-4;
4+
const d = 0x1E+4;
5+
6+
// error
7+
// backend=stage2
8+
// target=native
9+
//
10+
// :1:15: error: sign '-' cannot follow digit 'e' in hex base
11+
// :2:15: error: sign '+' cannot follow digit 'e' in hex base
12+
// :3:15: error: sign '-' cannot follow digit 'E' in hex base
13+
// :4:15: error: sign '+' cannot follow digit 'E' in hex base

0 commit comments

Comments
 (0)