mirror of
https://github.com/ziglang/zig.git
synced 2024-11-21 19:42:56 +00:00
Merge 4a20da167d
into f845fa04a0
This commit is contained in:
commit
9b2a18d30a
2
lib/compiler/aro/aro/Parser.zig
vendored
2
lib/compiler/aro/aro/Parser.zig
vendored
@ -979,7 +979,7 @@ fn decl(p: *Parser) Error!bool {
|
||||
_ = try p.expectToken(.semicolon);
|
||||
if (decl_spec.ty.is(.@"enum") or
|
||||
(decl_spec.ty.isRecord() and !decl_spec.ty.isAnonymousRecord(p.comp) and
|
||||
!decl_spec.ty.isTypeof())) // we follow GCC and clang's behavior here
|
||||
!decl_spec.ty.isTypeof())) // we follow GCC and clang's behavior here
|
||||
{
|
||||
const specifier = decl_spec.ty.canonicalize(.standard).specifier;
|
||||
const attrs = p.attr_buf.items(.attr)[attr_buf_top..];
|
||||
|
6
lib/compiler/aro/aro/pragmas/gcc.zig
vendored
6
lib/compiler/aro/aro/pragmas/gcc.zig
vendored
@ -114,9 +114,9 @@ fn preprocessorHandler(pragma: *Pragma, pp: *Preprocessor, start_idx: TokenIndex
|
||||
|
||||
const gcc_pragma = std.meta.stringToEnum(Directive, pp.expandedSlice(directive_tok)) orelse
|
||||
return pp.comp.addDiagnostic(.{
|
||||
.tag = .unknown_gcc_pragma,
|
||||
.loc = directive_tok.loc,
|
||||
}, pp.expansionSlice(start_idx + 1));
|
||||
.tag = .unknown_gcc_pragma,
|
||||
.loc = directive_tok.loc,
|
||||
}, pp.expansionSlice(start_idx + 1));
|
||||
|
||||
switch (gcc_pragma) {
|
||||
.warning, .@"error" => {
|
||||
|
@ -255,7 +255,7 @@ pub fn parse(lang_tag: []const u8) error{InvalidLanguageTag}!Parsed {
|
||||
// Special case for qps-ploca and qps-plocm
|
||||
else if (std.ascii.eqlIgnoreCase(lang_code, "qps") and
|
||||
(std.ascii.eqlIgnoreCase(part_str, "ploca") or
|
||||
std.ascii.eqlIgnoreCase(part_str, "plocm")))
|
||||
std.ascii.eqlIgnoreCase(part_str, "plocm")))
|
||||
{
|
||||
parsed.suffix = part_str;
|
||||
} else {
|
||||
|
@ -143,7 +143,7 @@ pub const __clzsi2 = switch (builtin.cpu.arch) {
|
||||
.arm, .armeb, .thumb, .thumbeb => impl: {
|
||||
const use_thumb1 =
|
||||
(builtin.cpu.arch.isThumb() or
|
||||
std.Target.arm.featureSetHas(builtin.cpu.features, .noarm)) and
|
||||
std.Target.arm.featureSetHas(builtin.cpu.features, .noarm)) and
|
||||
!std.Target.arm.featureSetHas(builtin.cpu.features, .thumb2);
|
||||
|
||||
if (use_thumb1) {
|
||||
|
@ -81,19 +81,19 @@ fn test_one_divmoddi4(a: i64, b: i64, expected_q: i64, expected_r: i64) !void {
|
||||
|
||||
const cases__divmoddi4 =
|
||||
[_][4]i64{
|
||||
[_]i64{ 0, 1, 0, 0 },
|
||||
[_]i64{ 0, -1, 0, 0 },
|
||||
[_]i64{ 2, 1, 2, 0 },
|
||||
[_]i64{ 2, -1, -2, 0 },
|
||||
[_]i64{ -2, 1, -2, 0 },
|
||||
[_]i64{ -2, -1, 2, 0 },
|
||||
[_]i64{ 7, 5, 1, 2 },
|
||||
[_]i64{ -7, 5, -1, -2 },
|
||||
[_]i64{ 19, 5, 3, 4 },
|
||||
[_]i64{ 19, -5, -3, 4 },
|
||||
[_]i64{ @as(i64, @bitCast(@as(u64, 0x8000000000000000))), 8, @as(i64, @bitCast(@as(u64, 0xf000000000000000))), 0 },
|
||||
[_]i64{ @as(i64, @bitCast(@as(u64, 0x8000000000000007))), 8, @as(i64, @bitCast(@as(u64, 0xf000000000000001))), -1 },
|
||||
};
|
||||
[_]i64{ 0, 1, 0, 0 },
|
||||
[_]i64{ 0, -1, 0, 0 },
|
||||
[_]i64{ 2, 1, 2, 0 },
|
||||
[_]i64{ 2, -1, -2, 0 },
|
||||
[_]i64{ -2, 1, -2, 0 },
|
||||
[_]i64{ -2, -1, 2, 0 },
|
||||
[_]i64{ 7, 5, 1, 2 },
|
||||
[_]i64{ -7, 5, -1, -2 },
|
||||
[_]i64{ 19, 5, 3, 4 },
|
||||
[_]i64{ 19, -5, -3, 4 },
|
||||
[_]i64{ @as(i64, @bitCast(@as(u64, 0x8000000000000000))), 8, @as(i64, @bitCast(@as(u64, 0xf000000000000000))), 0 },
|
||||
[_]i64{ @as(i64, @bitCast(@as(u64, 0x8000000000000007))), 8, @as(i64, @bitCast(@as(u64, 0xf000000000000001))), -1 },
|
||||
};
|
||||
|
||||
test "test_divmoddi4" {
|
||||
for (cases__divmoddi4) |case| {
|
||||
@ -215,19 +215,19 @@ pub fn __divmodsi4(a: i32, b: i32, rem: *i32) callconv(.C) i32 {
|
||||
|
||||
const cases__divmodsi4 =
|
||||
[_][4]i32{
|
||||
[_]i32{ 0, 1, 0, 0 },
|
||||
[_]i32{ 0, -1, 0, 0 },
|
||||
[_]i32{ 2, 1, 2, 0 },
|
||||
[_]i32{ 2, -1, -2, 0 },
|
||||
[_]i32{ -2, 1, -2, 0 },
|
||||
[_]i32{ -2, -1, 2, 0 },
|
||||
[_]i32{ 7, 5, 1, 2 },
|
||||
[_]i32{ -7, 5, -1, -2 },
|
||||
[_]i32{ 19, 5, 3, 4 },
|
||||
[_]i32{ 19, -5, -3, 4 },
|
||||
[_]i32{ @bitCast(@as(u32, 0x80000000)), 8, @bitCast(@as(u32, 0xf0000000)), 0 },
|
||||
[_]i32{ @bitCast(@as(u32, 0x80000007)), 8, @bitCast(@as(u32, 0xf0000001)), -1 },
|
||||
};
|
||||
[_]i32{ 0, 1, 0, 0 },
|
||||
[_]i32{ 0, -1, 0, 0 },
|
||||
[_]i32{ 2, 1, 2, 0 },
|
||||
[_]i32{ 2, -1, -2, 0 },
|
||||
[_]i32{ -2, 1, -2, 0 },
|
||||
[_]i32{ -2, -1, 2, 0 },
|
||||
[_]i32{ 7, 5, 1, 2 },
|
||||
[_]i32{ -7, 5, -1, -2 },
|
||||
[_]i32{ 19, 5, 3, 4 },
|
||||
[_]i32{ 19, -5, -3, 4 },
|
||||
[_]i32{ @bitCast(@as(u32, 0x80000000)), 8, @bitCast(@as(u32, 0xf0000000)), 0 },
|
||||
[_]i32{ @bitCast(@as(u32, 0x80000007)), 8, @bitCast(@as(u32, 0xf0000001)), -1 },
|
||||
};
|
||||
|
||||
fn test_one_divmodsi4(a: i32, b: i32, expected_q: i32, expected_r: i32) !void {
|
||||
var r: i32 = undefined;
|
||||
|
@ -40,7 +40,7 @@ inline fn popcountXi2(comptime ST: type, a: ST) i32 {
|
||||
var x: UT = @bitCast(a);
|
||||
x -= (x >> 1) & (~@as(UT, 0) / 3); // 0x55...55, aggregate duos
|
||||
x = ((x >> 2) & (~@as(UT, 0) / 5)) // 0x33...33, aggregate nibbles
|
||||
+ (x & (~@as(UT, 0) / 5));
|
||||
+ (x & (~@as(UT, 0) / 5));
|
||||
x += x >> 4;
|
||||
x &= ~@as(UT, 0) / 17; // 0x0F...0F, aggregate bytes
|
||||
// 8 most significant bits of x + (x<<8) + (x<<16) + ..
|
||||
|
@ -374,7 +374,7 @@ fn appendBlockStart(p: *Parser, block_start: BlockStart) !void {
|
||||
// or not of the same marker type.
|
||||
const should_close_list = last_pending_block.tag == .list and
|
||||
(block_start.tag != .list_item or
|
||||
block_start.data.list_item.marker != last_pending_block.data.list.marker);
|
||||
block_start.data.list_item.marker != last_pending_block.data.list.marker);
|
||||
// The last block should also be closed if the new block is not a table
|
||||
// row, which is the only allowed child of a table.
|
||||
const should_close_table = last_pending_block.tag == .table and
|
||||
|
@ -325,7 +325,7 @@ pub const Os = struct {
|
||||
pub fn parse(str: []const u8) !WindowsVersion {
|
||||
return std.meta.stringToEnum(WindowsVersion, str) orelse
|
||||
@enumFromInt(std.fmt.parseInt(u32, str, 0) catch
|
||||
return error.InvalidOperatingSystemVersion);
|
||||
return error.InvalidOperatingSystemVersion);
|
||||
}
|
||||
|
||||
/// This function is defined to serialize a Zig source code representation of this
|
||||
|
@ -9592,10 +9592,10 @@ pub extern "c" fn setlocale(category: LC, locale: ?[*:0]const u8) ?[*:0]const u8
|
||||
|
||||
pub const getcontext = if (builtin.target.isAndroid() or builtin.target.os.tag == .openbsd)
|
||||
{} // android bionic and openbsd libc does not implement getcontext
|
||||
else if (native_os == .linux and builtin.target.isMusl())
|
||||
linux.getcontext
|
||||
else
|
||||
private.getcontext;
|
||||
else if (native_os == .linux and builtin.target.isMusl())
|
||||
linux.getcontext
|
||||
else
|
||||
private.getcontext;
|
||||
|
||||
pub const max_align_t = if (native_abi == .msvc or native_abi == .itanium)
|
||||
f64
|
||||
|
@ -706,7 +706,7 @@ pub fn init(stream: anytype, options: Options) InitError(@TypeOf(stream))!Client
|
||||
const client_key_exchange_msg = .{@intFromEnum(tls.ContentType.handshake)} ++
|
||||
int(u16, @intFromEnum(tls.ProtocolVersion.tls_1_2)) ++
|
||||
array(u16, u8, .{@intFromEnum(tls.HandshakeType.client_key_exchange)} ++
|
||||
array(u24, u8, array(u8, u8, key_share.secp256r1_kp.public_key.toUncompressedSec1())));
|
||||
array(u24, u8, array(u8, u8, key_share.secp256r1_kp.public_key.toUncompressedSec1())));
|
||||
const client_change_cipher_spec_msg = .{@intFromEnum(tls.ContentType.change_cipher_spec)} ++
|
||||
int(u16, @intFromEnum(tls.ProtocolVersion.tls_1_2)) ++
|
||||
array(u16, tls.ChangeCipherSpecType, .{.change_cipher_spec});
|
||||
@ -734,11 +734,11 @@ pub fn init(stream: anytype, options: Options) InitError(@TypeOf(stream))!Client
|
||||
);
|
||||
const client_verify_cleartext = .{@intFromEnum(tls.HandshakeType.finished)} ++
|
||||
array(u24, u8, hmacExpandLabel(
|
||||
P.Hmac,
|
||||
&master_secret,
|
||||
&.{ "client finished", &p.transcript_hash.peek() },
|
||||
P.verify_data_length,
|
||||
));
|
||||
P.Hmac,
|
||||
&master_secret,
|
||||
&.{ "client finished", &p.transcript_hash.peek() },
|
||||
P.verify_data_length,
|
||||
));
|
||||
p.transcript_hash.update(&client_verify_cleartext);
|
||||
p.version = .{ .tls_1_2 = .{
|
||||
.expected_server_verify_data = hmacExpandLabel(
|
||||
@ -766,7 +766,7 @@ pub fn init(stream: anytype, options: Options) InitError(@TypeOf(stream))!Client
|
||||
var client_verify_msg = .{@intFromEnum(tls.ContentType.handshake)} ++
|
||||
int(u16, @intFromEnum(tls.ProtocolVersion.tls_1_2)) ++
|
||||
array(u16, u8, nonce[P.fixed_iv_length..].* ++
|
||||
@as([client_verify_cleartext.len + P.mac_length]u8, undefined));
|
||||
@as([client_verify_cleartext.len + P.mac_length]u8, undefined));
|
||||
P.AEAD.encrypt(
|
||||
client_verify_msg[client_verify_msg.len - P.mac_length -
|
||||
client_verify_cleartext.len ..][0..client_verify_cleartext.len],
|
||||
|
@ -689,15 +689,15 @@ pub const Module = switch (native_os) {
|
||||
const o_file_path = mem.sliceTo(self.strings[symbol.ofile..], 0);
|
||||
const o_file_info = self.ofiles.getPtr(o_file_path) orelse
|
||||
(self.loadOFile(allocator, o_file_path) catch |err| switch (err) {
|
||||
error.FileNotFound,
|
||||
error.MissingDebugInfo,
|
||||
error.InvalidDebugInfo,
|
||||
=> return .{
|
||||
.relocated_address = relocated_address,
|
||||
.symbol = symbol,
|
||||
},
|
||||
else => return err,
|
||||
});
|
||||
error.FileNotFound,
|
||||
error.MissingDebugInfo,
|
||||
error.InvalidDebugInfo,
|
||||
=> return .{
|
||||
.relocated_address = relocated_address,
|
||||
.symbol = symbol,
|
||||
},
|
||||
else => return err,
|
||||
});
|
||||
|
||||
return .{
|
||||
.relocated_address = relocated_address,
|
||||
|
@ -959,14 +959,14 @@ pub const Request = struct {
|
||||
|
||||
pub const WaitError = RequestError || SendError || TransferReadError ||
|
||||
proto.HeadersParser.CheckCompleteHeadError || Response.ParseError ||
|
||||
error{ // TODO: file zig fmt issue for this bad indentation
|
||||
TooManyHttpRedirects,
|
||||
RedirectRequiresResend,
|
||||
HttpRedirectLocationMissing,
|
||||
HttpRedirectLocationInvalid,
|
||||
CompressionInitializationFailed,
|
||||
CompressionUnsupported,
|
||||
};
|
||||
error{
|
||||
TooManyHttpRedirects,
|
||||
RedirectRequiresResend,
|
||||
HttpRedirectLocationMissing,
|
||||
HttpRedirectLocationInvalid,
|
||||
CompressionInitializationFailed,
|
||||
CompressionUnsupported,
|
||||
};
|
||||
|
||||
/// Waits for a response from the server and parses any headers that are sent.
|
||||
/// This function will block until the final response is received.
|
||||
@ -1539,13 +1539,13 @@ pub fn connect(
|
||||
|
||||
pub const RequestError = ConnectTcpError || ConnectErrorPartial || Request.SendError ||
|
||||
std.fmt.ParseIntError || Connection.WriteError ||
|
||||
error{ // TODO: file a zig fmt issue for this bad indentation
|
||||
UnsupportedUriScheme,
|
||||
UriMissingHost,
|
||||
error{
|
||||
UnsupportedUriScheme,
|
||||
UriMissingHost,
|
||||
|
||||
CertificateBundleLoadFailure,
|
||||
UnsupportedTransferEncoding,
|
||||
};
|
||||
CertificateBundleLoadFailure,
|
||||
UnsupportedTransferEncoding,
|
||||
};
|
||||
|
||||
pub const RequestOptions = struct {
|
||||
version: http.Version = .@"HTTP/1.1",
|
||||
|
@ -2836,12 +2836,12 @@ pub fn renameatW(
|
||||
|
||||
rc =
|
||||
windows.ntdll.NtSetInformationFile(
|
||||
src_fd,
|
||||
&io_status_block,
|
||||
rename_info,
|
||||
@intCast(struct_len), // already checked for error.NameTooLong
|
||||
.FileRenameInformation,
|
||||
);
|
||||
src_fd,
|
||||
&io_status_block,
|
||||
rename_info,
|
||||
@intCast(struct_len), // already checked for error.NameTooLong
|
||||
.FileRenameInformation,
|
||||
);
|
||||
}
|
||||
|
||||
switch (rc) {
|
||||
|
@ -1776,7 +1776,7 @@ test "zig fmt: if nested" {
|
||||
\\ GE_EQUAL
|
||||
\\ else
|
||||
\\ GE_GREATER
|
||||
\\ // comment
|
||||
\\ // comment
|
||||
\\ else if (aInt > bInt)
|
||||
\\ GE_LESS
|
||||
\\ else if (aInt == bInt)
|
||||
@ -4670,7 +4670,7 @@ test "zig fmt: test comments in field access chain" {
|
||||
\\ .more() //
|
||||
\\ .more().more() //
|
||||
\\ .more() //
|
||||
\\ // .more() //
|
||||
\\ // .more() //
|
||||
\\ .more() //
|
||||
\\ .more();
|
||||
\\ data: Data,
|
||||
@ -4679,9 +4679,9 @@ test "zig fmt: test comments in field access chain" {
|
||||
\\pub const str = struct {
|
||||
\\ pub const Thing = more.more //
|
||||
\\ .more() //
|
||||
\\ // .more() //
|
||||
\\ // .more() //
|
||||
\\ // .more() //
|
||||
\\ // .more() //
|
||||
\\ // .more() //
|
||||
\\ // .more() //
|
||||
\\ .more() //
|
||||
\\ .more();
|
||||
\\ data: Data,
|
||||
@ -4706,7 +4706,7 @@ test "zig fmt: allow line break before field access" {
|
||||
\\ const x = foo
|
||||
\\ .bar()
|
||||
\\ . // comment
|
||||
\\ // comment
|
||||
\\ // comment
|
||||
\\ swooop().zippy(zag)
|
||||
\\ .iguessthisisok();
|
||||
\\
|
||||
@ -4716,7 +4716,7 @@ test "zig fmt: allow line break before field access" {
|
||||
\\ .input_manager //
|
||||
\\ .default_seat
|
||||
\\ . // comment
|
||||
\\ // another comment
|
||||
\\ // another comment
|
||||
\\ wlr_seat.name;
|
||||
\\}
|
||||
\\
|
||||
@ -4955,19 +4955,19 @@ test "zig fmt: use of comments and multiline string literals may force the param
|
||||
\\
|
||||
\\// This looks like garbage don't do this
|
||||
\\const rparen = tree.prevToken(
|
||||
\\// the first token for the annotation expressions is the left
|
||||
\\// parenthesis, hence the need for two prevToken
|
||||
\\if (fn_proto.getAlignExpr()) |align_expr|
|
||||
\\ tree.prevToken(tree.prevToken(align_expr.firstToken()))
|
||||
\\else if (fn_proto.getSectionExpr()) |section_expr|
|
||||
\\ tree.prevToken(tree.prevToken(section_expr.firstToken()))
|
||||
\\else if (fn_proto.getCallconvExpr()) |callconv_expr|
|
||||
\\ tree.prevToken(tree.prevToken(callconv_expr.firstToken()))
|
||||
\\else switch (fn_proto.return_type) {
|
||||
\\ .Explicit => |node| node.firstToken(),
|
||||
\\ .InferErrorSet => |node| tree.prevToken(node.firstToken()),
|
||||
\\ .Invalid => unreachable,
|
||||
\\});
|
||||
\\ // the first token for the annotation expressions is the left
|
||||
\\ // parenthesis, hence the need for two prevToken
|
||||
\\ if (fn_proto.getAlignExpr()) |align_expr|
|
||||
\\ tree.prevToken(tree.prevToken(align_expr.firstToken()))
|
||||
\\ else if (fn_proto.getSectionExpr()) |section_expr|
|
||||
\\ tree.prevToken(tree.prevToken(section_expr.firstToken()))
|
||||
\\ else if (fn_proto.getCallconvExpr()) |callconv_expr|
|
||||
\\ tree.prevToken(tree.prevToken(callconv_expr.firstToken()))
|
||||
\\ else switch (fn_proto.return_type) {
|
||||
\\ .Explicit => |node| node.firstToken(),
|
||||
\\ .InferErrorSet => |node| tree.prevToken(node.firstToken()),
|
||||
\\ .Invalid => unreachable,
|
||||
\\ });
|
||||
\\
|
||||
);
|
||||
}
|
||||
@ -5962,6 +5962,151 @@ test "zig fmt: pointer type syntax to index" {
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: binop indentation in if statement" {
|
||||
try testCanonical(
|
||||
\\test {
|
||||
\\ if (first_param_type.isGenericPoison() or
|
||||
\\ (first_param_type.zigTypeTag(zcu) == .pointer and
|
||||
\\ (first_param_type.ptrSize(zcu) == .One or
|
||||
\\ first_param_type.ptrSize(zcu) == .C) and
|
||||
\\ first_param_type.childType(zcu).eql(concrete_ty, zcu)))
|
||||
\\ {
|
||||
\\ f(x);
|
||||
\\ }
|
||||
\\}
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: test indentation after equals sign" {
|
||||
try testCanonical(
|
||||
\\test {
|
||||
\\ const foo =
|
||||
\\ if (1 == 2)
|
||||
\\ 1
|
||||
\\ else if (3 > 4)
|
||||
\\ 2
|
||||
\\ else
|
||||
\\ 0;
|
||||
\\
|
||||
\\ const foo, const bar =
|
||||
\\ if (1 == 2)
|
||||
\\ .{ 0, 0 }
|
||||
\\ else if (3 > 4)
|
||||
\\ .{ 1, 1 }
|
||||
\\ else
|
||||
\\ .{ 2, 2 };
|
||||
\\
|
||||
\\ while (foo) if (bar)
|
||||
\\ f(x);
|
||||
\\
|
||||
\\ foobar =
|
||||
\\ if (true)
|
||||
\\ 1
|
||||
\\ else
|
||||
\\ 0;
|
||||
\\
|
||||
\\ const foo = if (1 == 2)
|
||||
\\ 1
|
||||
\\ else if (3 > 4)
|
||||
\\ 2
|
||||
\\ else
|
||||
\\ 0;
|
||||
\\
|
||||
\\ const foo, const bar = if (1 == 2)
|
||||
\\ .{ 0, 0 }
|
||||
\\ else if (3 > 4)
|
||||
\\ .{ 1, 1 }
|
||||
\\ else
|
||||
\\ .{ 2, 2 };
|
||||
\\
|
||||
\\ foobar = if (true)
|
||||
\\ 1
|
||||
\\ else
|
||||
\\ 0;
|
||||
\\
|
||||
\\ const is_alphanum =
|
||||
\\ (ch >= 'a' and ch <= 'z') or
|
||||
\\ (ch >= 'A' and ch <= 'Z') or
|
||||
\\ (ch >= '0' and ch <= '9');
|
||||
\\
|
||||
\\ const bar = 100 + calculate(
|
||||
\\ 200,
|
||||
\\ 300,
|
||||
\\ );
|
||||
\\
|
||||
\\ const gcc_pragma = std.meta.stringToEnum(Directive, pp.expandedSlice(directive_tok)) orelse
|
||||
\\ return pp.comp.addDiagnostic(.{
|
||||
\\ .tag = .unknown_gcc_pragma,
|
||||
\\ .loc = directive_tok.loc,
|
||||
\\ }, pp.expansionSlice(start_idx + 1));
|
||||
\\
|
||||
\\ const vec4s =
|
||||
\\ [_][4]i32{
|
||||
\\ [_]i32{ 0, 1, 0, 0 },
|
||||
\\ [_]i32{ 0, -1, 0, 0 },
|
||||
\\ [_]i32{ 2, 1, 2, 0 },
|
||||
\\ };
|
||||
\\}
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: test indentation of if expressions" {
|
||||
try testCanonical(
|
||||
\\test {
|
||||
\\ const foo = 1 +
|
||||
\\ if (1 == 2)
|
||||
\\ 2
|
||||
\\ else
|
||||
\\ 0;
|
||||
\\
|
||||
\\ const foo = 1 + if (1 == 2)
|
||||
\\ 2
|
||||
\\ else
|
||||
\\ 0;
|
||||
\\
|
||||
\\ errval catch |e|
|
||||
\\ if (e == error.Meow)
|
||||
\\ return 0x1F408
|
||||
\\ else
|
||||
\\ unreachable;
|
||||
\\
|
||||
\\ errval catch |e| if (e == error.Meow)
|
||||
\\ return 0x1F408
|
||||
\\ else
|
||||
\\ unreachable;
|
||||
\\
|
||||
\\ return if (1 == 2)
|
||||
\\ 1
|
||||
\\ else if (3 > 4)
|
||||
\\ 2
|
||||
\\ else
|
||||
\\ 0;
|
||||
\\}
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: indentation of comments within catch, else, orelse" {
|
||||
try testCanonical(
|
||||
\\comptime {
|
||||
\\ _ = foo() catch
|
||||
\\ //
|
||||
\\ bar();
|
||||
\\
|
||||
\\ _ = if (foo) bar() else
|
||||
\\ //
|
||||
\\ qux();
|
||||
\\
|
||||
\\ _ = foo() orelse
|
||||
\\ //
|
||||
\\ qux();
|
||||
\\}
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
test "recovery: top level" {
|
||||
try testError(
|
||||
\\test "" {inline}
|
||||
|
File diff suppressed because it is too large
Load Diff
24
src/Sema.zig
24
src/Sema.zig
@ -23799,7 +23799,7 @@ fn ptrCastFull(
|
||||
errdefer msg.destroy(sema.gpa);
|
||||
if (dest_info.flags.size == .Many and
|
||||
(src_info.flags.size == .Slice or
|
||||
(src_info.flags.size == .One and Type.fromInterned(src_info.child).zigTypeTag(zcu) == .array)))
|
||||
(src_info.flags.size == .One and Type.fromInterned(src_info.child).zigTypeTag(zcu) == .array)))
|
||||
{
|
||||
try sema.errNote(src, msg, "use 'ptr' field to convert slice to many pointer", .{});
|
||||
} else {
|
||||
@ -28828,9 +28828,9 @@ fn fieldCallBind(
|
||||
const first_param_type = Type.fromInterned(func_type.param_types.get(ip)[0]);
|
||||
if (first_param_type.isGenericPoison() or
|
||||
(first_param_type.zigTypeTag(zcu) == .pointer and
|
||||
(first_param_type.ptrSize(zcu) == .One or
|
||||
first_param_type.ptrSize(zcu) == .C) and
|
||||
first_param_type.childType(zcu).eql(concrete_ty, zcu)))
|
||||
(first_param_type.ptrSize(zcu) == .One or
|
||||
first_param_type.ptrSize(zcu) == .C) and
|
||||
first_param_type.childType(zcu).eql(concrete_ty, zcu)))
|
||||
{
|
||||
// Note that if the param type is generic poison, we know that it must
|
||||
// specifically be `anytype` since it's the first parameter, meaning we
|
||||
@ -30363,7 +30363,7 @@ fn coerceExtra(
|
||||
|
||||
if (dest_info.sentinel == .none or inst_info.sentinel == .none or
|
||||
Air.internedToRef(dest_info.sentinel) !=
|
||||
try sema.coerceInMemory(Value.fromInterned(inst_info.sentinel), Type.fromInterned(dest_info.child)))
|
||||
try sema.coerceInMemory(Value.fromInterned(inst_info.sentinel), Type.fromInterned(dest_info.child)))
|
||||
break :p;
|
||||
|
||||
const slice_ptr = try sema.analyzeSlicePtr(block, inst_src, inst, inst_ty);
|
||||
@ -31186,12 +31186,12 @@ pub fn coerceInMemoryAllowed(
|
||||
}
|
||||
const ok_sent = (dest_info.sentinel == null and src_info.sentinel == null) or
|
||||
(src_info.sentinel != null and
|
||||
dest_info.sentinel != null and
|
||||
dest_info.sentinel.?.eql(
|
||||
try pt.getCoerced(src_info.sentinel.?, dest_info.elem_type),
|
||||
dest_info.elem_type,
|
||||
zcu,
|
||||
));
|
||||
dest_info.sentinel != null and
|
||||
dest_info.sentinel.?.eql(
|
||||
try pt.getCoerced(src_info.sentinel.?, dest_info.elem_type),
|
||||
dest_info.elem_type,
|
||||
zcu,
|
||||
));
|
||||
if (!ok_sent) {
|
||||
return InMemoryCoercionResult{ .array_sentinel = .{
|
||||
.actual = src_info.sentinel orelse Value.@"unreachable",
|
||||
@ -31642,7 +31642,7 @@ fn coerceInMemoryAllowedPtrs(
|
||||
|
||||
const ok_sent = dest_info.sentinel == .none or src_info.flags.size == .C or
|
||||
(src_info.sentinel != .none and
|
||||
dest_info.sentinel == try zcu.intern_pool.getCoerced(sema.gpa, pt.tid, src_info.sentinel, dest_info.child));
|
||||
dest_info.sentinel == try zcu.intern_pool.getCoerced(sema.gpa, pt.tid, src_info.sentinel, dest_info.child));
|
||||
if (!ok_sent) {
|
||||
return InMemoryCoercionResult{ .ptr_sentinel = .{
|
||||
.actual = switch (src_info.sentinel) {
|
||||
|
11
src/Type.zig
11
src/Type.zig
@ -607,11 +607,12 @@ pub fn hasRuntimeBitsInner(
|
||||
// in which case we want control flow to continue down below.
|
||||
if (tag_ty != .none and
|
||||
try Type.fromInterned(tag_ty).hasRuntimeBitsInner(
|
||||
ignore_comptime_only,
|
||||
strat,
|
||||
zcu,
|
||||
tid,
|
||||
)) {
|
||||
ignore_comptime_only,
|
||||
strat,
|
||||
zcu,
|
||||
tid,
|
||||
))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
@ -1195,8 +1195,8 @@ pub const SrcLoc = struct {
|
||||
const case = tree.fullSwitchCase(case_node).?;
|
||||
const is_special = (case.ast.values.len == 0) or
|
||||
(case.ast.values.len == 1 and
|
||||
node_tags[case.ast.values[0]] == .identifier and
|
||||
mem.eql(u8, tree.tokenSlice(main_tokens[case.ast.values[0]]), "_"));
|
||||
node_tags[case.ast.values[0]] == .identifier and
|
||||
mem.eql(u8, tree.tokenSlice(main_tokens[case.ast.values[0]]), "_"));
|
||||
if (!is_special) continue;
|
||||
|
||||
return tree.nodeToSpan(case_node);
|
||||
@ -1215,8 +1215,8 @@ pub const SrcLoc = struct {
|
||||
const case = tree.fullSwitchCase(case_node).?;
|
||||
const is_special = (case.ast.values.len == 0) or
|
||||
(case.ast.values.len == 1 and
|
||||
node_tags[case.ast.values[0]] == .identifier and
|
||||
mem.eql(u8, tree.tokenSlice(main_tokens[case.ast.values[0]]), "_"));
|
||||
node_tags[case.ast.values[0]] == .identifier and
|
||||
mem.eql(u8, tree.tokenSlice(main_tokens[case.ast.values[0]]), "_"));
|
||||
if (is_special) continue;
|
||||
|
||||
for (case.ast.values) |item_node| {
|
||||
|
@ -685,8 +685,7 @@ fn restoreState(func: *Func, state: State, deaths: []const Air.Inst.Index, compt
|
||||
|
||||
const ExpectedContents = [@typeInfo(RegisterManager.TrackedRegisters).array.len]RegisterLock;
|
||||
var stack align(@max(@alignOf(ExpectedContents), @alignOf(std.heap.StackFallbackAllocator(0)))) =
|
||||
if (opts.update_tracking)
|
||||
{} else std.heap.stackFallback(@sizeOf(ExpectedContents), func.gpa);
|
||||
if (opts.update_tracking) {} else std.heap.stackFallback(@sizeOf(ExpectedContents), func.gpa);
|
||||
|
||||
var reg_locks = if (opts.update_tracking) {} else try std.ArrayList(RegisterLock).initCapacity(
|
||||
stack.get(),
|
||||
@ -2303,7 +2302,7 @@ fn airIntCast(func: *Func, inst: Air.Inst.Index) !void {
|
||||
|
||||
const dst_mcv = if (dst_int_info.bits <= src_storage_bits and
|
||||
math.divCeil(u16, dst_int_info.bits, 64) catch unreachable ==
|
||||
math.divCeil(u32, src_storage_bits, 64) catch unreachable and
|
||||
math.divCeil(u32, src_storage_bits, 64) catch unreachable and
|
||||
func.reuseOperand(inst, ty_op.operand, 0, src_mcv)) src_mcv else dst: {
|
||||
const dst_mcv = try func.allocRegOrMem(dst_ty, inst, true);
|
||||
try func.genCopy(min_ty, dst_mcv, src_mcv);
|
||||
@ -2361,9 +2360,9 @@ fn airNot(func: *Func, inst: Air.Inst.Index) !void {
|
||||
|
||||
const dst_reg: Register =
|
||||
if (func.reuseOperand(inst, ty_op.operand, 0, operand) and operand == .register)
|
||||
operand.register
|
||||
else
|
||||
(try func.allocRegOrMem(func.typeOfIndex(inst), inst, true)).register;
|
||||
operand.register
|
||||
else
|
||||
(try func.allocRegOrMem(func.typeOfIndex(inst), inst, true)).register;
|
||||
|
||||
switch (ty.zigTypeTag(zcu)) {
|
||||
.bool => {
|
||||
@ -6271,11 +6270,11 @@ fn airAsm(func: *Func, inst: Air.Inst.Index) !void {
|
||||
|
||||
const instruction: union(enum) { mnem: Mnemonic, pseudo: Pseudo } =
|
||||
if (std.meta.stringToEnum(Mnemonic, mnem_str)) |mnem|
|
||||
.{ .mnem = mnem }
|
||||
else if (std.meta.stringToEnum(Pseudo, mnem_str)) |pseudo|
|
||||
.{ .pseudo = pseudo }
|
||||
else
|
||||
return func.fail("invalid mnem str '{s}'", .{mnem_str});
|
||||
.{ .mnem = mnem }
|
||||
else if (std.meta.stringToEnum(Pseudo, mnem_str)) |pseudo|
|
||||
.{ .pseudo = pseudo }
|
||||
else
|
||||
return func.fail("invalid mnem str '{s}'", .{mnem_str});
|
||||
|
||||
const Operand = union(enum) {
|
||||
none,
|
||||
|
@ -4411,12 +4411,12 @@ fn processDeath(self: *Self, inst: Air.Inst.Index) void {
|
||||
|
||||
/// Turns stack_offset MCV into a real SPARCv9 stack offset usable for asm.
|
||||
fn realStackOffset(off: u32) u32 {
|
||||
return off
|
||||
// SPARCv9 %sp points away from the stack by some amount.
|
||||
+ abi.stack_bias
|
||||
// The first couple bytes of each stack frame is reserved
|
||||
// for ABI and hardware purposes.
|
||||
+ abi.stack_reserved_area;
|
||||
return off +
|
||||
// SPARCv9 %sp points away from the stack by some amount.
|
||||
abi.stack_bias +
|
||||
// The first couple bytes of each stack frame is reserved
|
||||
// for ABI and hardware purposes.
|
||||
abi.stack_reserved_area;
|
||||
// Only after that we have the usable stack frame portion.
|
||||
}
|
||||
|
||||
|
@ -2919,8 +2919,7 @@ fn restoreState(self: *Self, state: State, deaths: []const Air.Inst.Index, compt
|
||||
|
||||
const ExpectedContents = [@typeInfo(RegisterManager.TrackedRegisters).array.len]RegisterLock;
|
||||
var stack align(@max(@alignOf(ExpectedContents), @alignOf(std.heap.StackFallbackAllocator(0)))) =
|
||||
if (opts.update_tracking)
|
||||
{} else std.heap.stackFallback(@sizeOf(ExpectedContents), self.gpa);
|
||||
if (opts.update_tracking) {} else std.heap.stackFallback(@sizeOf(ExpectedContents), self.gpa);
|
||||
|
||||
var reg_locks = if (opts.update_tracking) {} else try std.ArrayList(RegisterLock).initCapacity(
|
||||
stack.get(),
|
||||
@ -3487,7 +3486,7 @@ fn airIntCast(self: *Self, inst: Air.Inst.Index) !void {
|
||||
|
||||
const dst_mcv = if (dst_int_info.bits <= src_storage_bits and
|
||||
math.divCeil(u16, dst_int_info.bits, 64) catch unreachable ==
|
||||
math.divCeil(u32, src_storage_bits, 64) catch unreachable and
|
||||
math.divCeil(u32, src_storage_bits, 64) catch unreachable and
|
||||
self.reuseOperand(inst, ty_op.operand, 0, src_mcv)) src_mcv else dst: {
|
||||
const dst_mcv = try self.allocRegOrMem(inst, true);
|
||||
try self.genCopy(min_ty, dst_mcv, src_mcv, .{});
|
||||
@ -5022,10 +5021,10 @@ fn genIntMulDivOpMir(self: *Self, tag: Mir.Inst.FixedTag, ty: Type, lhs: MCValue
|
||||
._ => {
|
||||
const hi_reg: Register =
|
||||
switch (bit_size) {
|
||||
8 => .ah,
|
||||
16, 32, 64 => .edx,
|
||||
else => unreachable,
|
||||
};
|
||||
8 => .ah,
|
||||
16, 32, 64 => .edx,
|
||||
else => unreachable,
|
||||
};
|
||||
try self.asmRegisterRegister(.{ ._, .xor }, hi_reg, hi_reg);
|
||||
},
|
||||
.i_ => try self.asmOpOnly(.{ ._, switch (bit_size) {
|
||||
@ -9349,9 +9348,9 @@ fn genShiftBinOpMir(
|
||||
.size = Memory.Size.fromSize(abi_size),
|
||||
.disp = math.cast(i32, @as(i64, @bitCast(addr))) orelse
|
||||
return self.fail("TODO genShiftBinOpMir between {s} and {s}", .{
|
||||
@tagName(lhs_mcv),
|
||||
@tagName(shift_mcv),
|
||||
}),
|
||||
@tagName(lhs_mcv),
|
||||
@tagName(shift_mcv),
|
||||
}),
|
||||
} },
|
||||
},
|
||||
.indirect => |reg_off| .{
|
||||
@ -10081,17 +10080,17 @@ fn genBinOp(
|
||||
|
||||
const ordered_air: [2]Air.Inst.Ref = if (lhs_ty.isVector(zcu) and
|
||||
switch (lhs_ty.childType(zcu).zigTypeTag(zcu)) {
|
||||
.bool => false,
|
||||
.int => switch (air_tag) {
|
||||
.cmp_lt, .cmp_gte => true,
|
||||
else => false,
|
||||
},
|
||||
.float => switch (air_tag) {
|
||||
.cmp_gte, .cmp_gt => true,
|
||||
else => false,
|
||||
},
|
||||
else => unreachable,
|
||||
}) .{ rhs_air, lhs_air } else .{ lhs_air, rhs_air };
|
||||
.bool => false,
|
||||
.int => switch (air_tag) {
|
||||
.cmp_lt, .cmp_gte => true,
|
||||
else => false,
|
||||
},
|
||||
.float => switch (air_tag) {
|
||||
.cmp_gte, .cmp_gt => true,
|
||||
else => false,
|
||||
},
|
||||
else => unreachable,
|
||||
}) .{ rhs_air, lhs_air } else .{ lhs_air, rhs_air };
|
||||
|
||||
if (lhs_ty.isAbiInt(zcu)) for (ordered_air) |op_air| {
|
||||
switch (try self.resolveInst(op_air)) {
|
||||
@ -12066,13 +12065,13 @@ fn genIntMulComplexOpMir(self: *Self, dst_ty: Type, dst_mcv: MCValue, src_mcv: M
|
||||
.size = Memory.Size.fromSize(abi_size),
|
||||
.disp = math.cast(i32, @as(i64, @bitCast(addr))) orelse
|
||||
return self.asmRegisterRegister(
|
||||
.{ .i_, .mul },
|
||||
dst_alias,
|
||||
registerAlias(
|
||||
try self.copyToTmpRegister(dst_ty, resolved_src_mcv),
|
||||
abi_size,
|
||||
.{ .i_, .mul },
|
||||
dst_alias,
|
||||
registerAlias(
|
||||
try self.copyToTmpRegister(dst_ty, resolved_src_mcv),
|
||||
abi_size,
|
||||
),
|
||||
),
|
||||
),
|
||||
} },
|
||||
},
|
||||
.indirect => |reg_off| .{
|
||||
@ -14165,9 +14164,9 @@ fn airAsm(self: *Self, inst: Air.Inst.Index) !void {
|
||||
mem.eql(u8, rest, "r,m") or mem.eql(u8, rest, "m,r"))
|
||||
self.register_manager.tryAllocReg(maybe_inst, abi.RegisterClass.gp) orelse
|
||||
if (output != .none)
|
||||
null
|
||||
else
|
||||
return self.fail("ran out of registers lowering inline asm", .{})
|
||||
null
|
||||
else
|
||||
return self.fail("ran out of registers lowering inline asm", .{})
|
||||
else if (mem.startsWith(u8, rest, "{") and mem.endsWith(u8, rest, "}"))
|
||||
parseRegName(rest["{".len .. rest.len - "}".len]) orelse
|
||||
return self.fail("invalid register constraint: '{s}'", .{constraint})
|
||||
@ -16607,9 +16606,9 @@ fn airAtomicLoad(self: *Self, inst: Air.Inst.Index) !void {
|
||||
|
||||
const dst_mcv =
|
||||
if (self.reuseOperand(inst, atomic_load.ptr, 0, ptr_mcv))
|
||||
ptr_mcv
|
||||
else
|
||||
try self.allocRegOrMem(inst, true);
|
||||
ptr_mcv
|
||||
else
|
||||
try self.allocRegOrMem(inst, true);
|
||||
|
||||
try self.load(dst_mcv, ptr_ty, ptr_mcv);
|
||||
return self.finishAir(inst, dst_mcv, .{ atomic_load.ptr, .none, .none });
|
||||
|
@ -418,17 +418,17 @@ fn emit(lower: *Lower, prefix: Prefix, mnemonic: Mnemonic, ops: []const Operand)
|
||||
_ = lower.reloc(.{ .linker_tlsld = sym_index }, 0);
|
||||
lower.result_insts[lower.result_insts_len] =
|
||||
try Instruction.new(.none, .lea, &[_]Operand{
|
||||
.{ .reg = .rdi },
|
||||
.{ .mem = Memory.initRip(mem_op.sib.ptr_size, 0) },
|
||||
});
|
||||
.{ .reg = .rdi },
|
||||
.{ .mem = Memory.initRip(mem_op.sib.ptr_size, 0) },
|
||||
});
|
||||
lower.result_insts_len += 1;
|
||||
_ = lower.reloc(.{
|
||||
.linker_extern_fn = try elf_file.getGlobalSymbol("__tls_get_addr", null),
|
||||
}, 0);
|
||||
lower.result_insts[lower.result_insts_len] =
|
||||
try Instruction.new(.none, .call, &[_]Operand{
|
||||
.{ .imm = Immediate.s(0) },
|
||||
});
|
||||
.{ .imm = Immediate.s(0) },
|
||||
});
|
||||
lower.result_insts_len += 1;
|
||||
_ = lower.reloc(.{ .linker_dtpoff = sym_index }, 0);
|
||||
emit_mnemonic = .lea;
|
||||
@ -440,9 +440,9 @@ fn emit(lower: *Lower, prefix: Prefix, mnemonic: Mnemonic, ops: []const Operand)
|
||||
// Since we are linking statically, we emit LE model directly.
|
||||
lower.result_insts[lower.result_insts_len] =
|
||||
try Instruction.new(.none, .mov, &[_]Operand{
|
||||
.{ .reg = .rax },
|
||||
.{ .mem = Memory.initSib(.qword, .{ .base = .{ .reg = .fs } }) },
|
||||
});
|
||||
.{ .reg = .rax },
|
||||
.{ .mem = Memory.initSib(.qword, .{ .base = .{ .reg = .fs } }) },
|
||||
});
|
||||
lower.result_insts_len += 1;
|
||||
_ = lower.reloc(.{ .linker_reloc = sym_index }, 0);
|
||||
emit_mnemonic = .lea;
|
||||
@ -464,9 +464,9 @@ fn emit(lower: *Lower, prefix: Prefix, mnemonic: Mnemonic, ops: []const Operand)
|
||||
const reg = ops[0].reg;
|
||||
lower.result_insts[lower.result_insts_len] =
|
||||
try Instruction.new(.none, .mov, &[_]Operand{
|
||||
.{ .reg = reg.to64() },
|
||||
.{ .mem = Memory.initRip(.qword, 0) },
|
||||
});
|
||||
.{ .reg = reg.to64() },
|
||||
.{ .mem = Memory.initRip(.qword, 0) },
|
||||
});
|
||||
lower.result_insts_len += 1;
|
||||
break :op .{ .mem = Memory.initSib(mem_op.sib.ptr_size, .{ .base = .{
|
||||
.reg = reg.to64(),
|
||||
@ -496,14 +496,14 @@ fn emit(lower: *Lower, prefix: Prefix, mnemonic: Mnemonic, ops: []const Operand)
|
||||
_ = lower.reloc(.{ .linker_reloc = sym_index }, 0);
|
||||
lower.result_insts[lower.result_insts_len] =
|
||||
try Instruction.new(.none, .mov, &[_]Operand{
|
||||
.{ .reg = .rdi },
|
||||
.{ .mem = Memory.initRip(mem_op.sib.ptr_size, 0) },
|
||||
});
|
||||
.{ .reg = .rdi },
|
||||
.{ .mem = Memory.initRip(mem_op.sib.ptr_size, 0) },
|
||||
});
|
||||
lower.result_insts_len += 1;
|
||||
lower.result_insts[lower.result_insts_len] =
|
||||
try Instruction.new(.none, .call, &[_]Operand{
|
||||
.{ .mem = Memory.initSib(.qword, .{ .base = .{ .reg = .rdi } }) },
|
||||
});
|
||||
.{ .mem = Memory.initSib(.qword, .{ .base = .{ .reg = .rdi } }) },
|
||||
});
|
||||
lower.result_insts_len += 1;
|
||||
emit_mnemonic = .mov;
|
||||
break :op .{ .reg = .rax };
|
||||
@ -520,9 +520,9 @@ fn emit(lower: *Lower, prefix: Prefix, mnemonic: Mnemonic, ops: []const Operand)
|
||||
const reg = ops[0].reg;
|
||||
lower.result_insts[lower.result_insts_len] =
|
||||
try Instruction.new(.none, .mov, &[_]Operand{
|
||||
.{ .reg = reg.to64() },
|
||||
.{ .mem = Memory.initRip(.qword, 0) },
|
||||
});
|
||||
.{ .reg = reg.to64() },
|
||||
.{ .mem = Memory.initRip(.qword, 0) },
|
||||
});
|
||||
lower.result_insts_len += 1;
|
||||
break :op .{ .mem = Memory.initSib(mem_op.sib.ptr_size, .{ .base = .{
|
||||
.reg = reg.to64(),
|
||||
|
@ -452,7 +452,7 @@ pub fn generateSymbol(
|
||||
|
||||
const padding = abi_size -
|
||||
(math.cast(usize, Type.fromInterned(vector_type.child).abiSize(zcu) * vector_type.len) orelse
|
||||
return error.Overflow);
|
||||
return error.Overflow);
|
||||
if (padding > 0) try code.appendNTimes(0, padding);
|
||||
}
|
||||
},
|
||||
|
@ -1921,7 +1921,7 @@ pub const DeclGen = struct {
|
||||
if (dest_bits <= 64 and src_bits <= 64) {
|
||||
const needs_cast = src_int_info == null or
|
||||
(toCIntBits(dest_int_info.bits) != toCIntBits(src_int_info.?.bits) or
|
||||
dest_int_info.signedness != src_int_info.?.signedness);
|
||||
dest_int_info.signedness != src_int_info.?.signedness);
|
||||
return !needs_cast and !src_is_ptr;
|
||||
} else return false;
|
||||
}
|
||||
@ -1962,7 +1962,7 @@ pub const DeclGen = struct {
|
||||
if (dest_bits <= 64 and src_bits <= 64) {
|
||||
const needs_cast = src_int_info == null or
|
||||
(toCIntBits(dest_int_info.bits) != toCIntBits(src_int_info.?.bits) or
|
||||
dest_int_info.signedness != src_int_info.?.signedness);
|
||||
dest_int_info.signedness != src_int_info.?.signedness);
|
||||
|
||||
if (needs_cast) {
|
||||
try w.writeByte('(');
|
||||
@ -4278,7 +4278,7 @@ fn airEquality(
|
||||
.aligned, .array, .vector, .fwd_decl, .function => unreachable,
|
||||
.aggregate => |aggregate| if (aggregate.fields.len == 2 and
|
||||
(aggregate.fields.at(0, ctype_pool).name.index == .is_null or
|
||||
aggregate.fields.at(1, ctype_pool).name.index == .is_null))
|
||||
aggregate.fields.at(1, ctype_pool).name.index == .is_null))
|
||||
{
|
||||
try f.writeCValueMember(writer, lhs, .{ .identifier = "is_null" });
|
||||
try writer.writeAll(" || ");
|
||||
|
@ -750,12 +750,12 @@ pub const Info = union(enum) {
|
||||
fn tag(pointer_info: Pointer) Pool.Tag {
|
||||
return @enumFromInt(@intFromEnum(Pool.Tag.pointer) +
|
||||
@as(u2, @bitCast(packed struct(u2) {
|
||||
@"const": bool,
|
||||
@"volatile": bool,
|
||||
}{
|
||||
.@"const" = pointer_info.@"const",
|
||||
.@"volatile" = pointer_info.@"volatile",
|
||||
})));
|
||||
@"const": bool,
|
||||
@"volatile": bool,
|
||||
}{
|
||||
.@"const" = pointer_info.@"const",
|
||||
.@"volatile" = pointer_info.@"volatile",
|
||||
})));
|
||||
}
|
||||
};
|
||||
|
||||
@ -879,24 +879,24 @@ pub const Info = union(enum) {
|
||||
pool_adapter.eql(lhs_vector_info.elem_ctype, rhs_info.vector.elem_ctype),
|
||||
.fwd_decl => |lhs_fwd_decl_info| lhs_fwd_decl_info.tag == rhs_info.fwd_decl.tag and
|
||||
switch (lhs_fwd_decl_info.name) {
|
||||
.anon => |lhs_anon| rhs_info.fwd_decl.name == .anon and lhs_anon.eqlAdapted(
|
||||
lhs_pool,
|
||||
rhs_info.fwd_decl.name.anon,
|
||||
rhs_pool,
|
||||
pool_adapter,
|
||||
),
|
||||
.index => |lhs_index| rhs_info.fwd_decl.name == .index and
|
||||
lhs_index == rhs_info.fwd_decl.name.index,
|
||||
},
|
||||
.anon => |lhs_anon| rhs_info.fwd_decl.name == .anon and lhs_anon.eqlAdapted(
|
||||
lhs_pool,
|
||||
rhs_info.fwd_decl.name.anon,
|
||||
rhs_pool,
|
||||
pool_adapter,
|
||||
),
|
||||
.index => |lhs_index| rhs_info.fwd_decl.name == .index and
|
||||
lhs_index == rhs_info.fwd_decl.name.index,
|
||||
},
|
||||
.aggregate => |lhs_aggregate_info| lhs_aggregate_info.tag == rhs_info.aggregate.tag and
|
||||
lhs_aggregate_info.@"packed" == rhs_info.aggregate.@"packed" and
|
||||
switch (lhs_aggregate_info.name) {
|
||||
.anon => |lhs_anon| rhs_info.aggregate.name == .anon and
|
||||
lhs_anon.index == rhs_info.aggregate.name.anon.index and
|
||||
lhs_anon.id == rhs_info.aggregate.name.anon.id,
|
||||
.fwd_decl => |lhs_fwd_decl| rhs_info.aggregate.name == .fwd_decl and
|
||||
pool_adapter.eql(lhs_fwd_decl, rhs_info.aggregate.name.fwd_decl),
|
||||
} and lhs_aggregate_info.fields.eqlAdapted(
|
||||
.anon => |lhs_anon| rhs_info.aggregate.name == .anon and
|
||||
lhs_anon.index == rhs_info.aggregate.name.anon.index and
|
||||
lhs_anon.id == rhs_info.aggregate.name.anon.id,
|
||||
.fwd_decl => |lhs_fwd_decl| rhs_info.aggregate.name == .fwd_decl and
|
||||
pool_adapter.eql(lhs_fwd_decl, rhs_info.aggregate.name.fwd_decl),
|
||||
} and lhs_aggregate_info.fields.eqlAdapted(
|
||||
lhs_pool,
|
||||
rhs_info.aggregate.fields,
|
||||
rhs_pool,
|
||||
@ -905,13 +905,12 @@ pub const Info = union(enum) {
|
||||
.function => |lhs_function_info| lhs_function_info.param_ctypes.len ==
|
||||
rhs_info.function.param_ctypes.len and
|
||||
pool_adapter.eql(lhs_function_info.return_ctype, rhs_info.function.return_ctype) and
|
||||
for (0..lhs_function_info.param_ctypes.len) |param_index|
|
||||
{
|
||||
if (!pool_adapter.eql(
|
||||
lhs_function_info.param_ctypes.at(param_index, lhs_pool),
|
||||
rhs_info.function.param_ctypes.at(param_index, rhs_pool),
|
||||
)) break false;
|
||||
} else true,
|
||||
for (0..lhs_function_info.param_ctypes.len) |param_index| {
|
||||
if (!pool_adapter.eql(
|
||||
lhs_function_info.param_ctypes.at(param_index, lhs_pool),
|
||||
rhs_info.function.param_ctypes.at(param_index, rhs_pool),
|
||||
)) break false;
|
||||
} else true,
|
||||
};
|
||||
}
|
||||
};
|
||||
@ -1947,13 +1946,13 @@ pub const Pool = struct {
|
||||
const return_type = Type.fromInterned(func_info.return_type);
|
||||
const return_ctype: CType =
|
||||
if (!ip.isNoReturn(func_info.return_type)) try pool.fromType(
|
||||
allocator,
|
||||
scratch,
|
||||
return_type,
|
||||
pt,
|
||||
mod,
|
||||
kind.asParameter(),
|
||||
) else CType.void;
|
||||
allocator,
|
||||
scratch,
|
||||
return_type,
|
||||
pt,
|
||||
mod,
|
||||
kind.asParameter(),
|
||||
) else CType.void;
|
||||
for (0..func_info.param_types.len) |param_index| {
|
||||
const param_type = Type.fromInterned(
|
||||
func_info.param_types.get(ip)[param_index],
|
||||
|
@ -486,7 +486,7 @@ const DataLayoutBuilder = struct {
|
||||
self.target.cpu.arch != .riscv64 and
|
||||
self.target.cpu.arch != .loongarch64 and
|
||||
!(self.target.cpu.arch == .aarch64 and
|
||||
(self.target.os.tag == .uefi or self.target.os.tag == .windows)) and
|
||||
(self.target.os.tag == .uefi or self.target.os.tag == .windows)) and
|
||||
self.target.cpu.arch != .bpfeb and self.target.cpu.arch != .bpfel) continue;
|
||||
try writer.writeAll("-p");
|
||||
if (info.llvm != .default) try writer.print("{d}", .{@intFromEnum(info.llvm)});
|
||||
@ -957,55 +957,54 @@ pub const Object = struct {
|
||||
builder.data_layout = try builder.fmt("{}", .{DataLayoutBuilder{ .target = target }});
|
||||
|
||||
const debug_compile_unit, const debug_enums_fwd_ref, const debug_globals_fwd_ref =
|
||||
if (!builder.strip)
|
||||
debug_info: {
|
||||
// We fully resolve all paths at this point to avoid lack of
|
||||
// source line info in stack traces or lack of debugging
|
||||
// information which, if relative paths were used, would be
|
||||
// very location dependent.
|
||||
// TODO: the only concern I have with this is WASI as either host or target, should
|
||||
// we leave the paths as relative then?
|
||||
// TODO: This is totally wrong. In dwarf, paths are encoded as relative to
|
||||
// a particular directory, and then the directory path is specified elsewhere.
|
||||
// In the compiler frontend we have it stored correctly in this
|
||||
// way already, but here we throw all that sweet information
|
||||
// into the garbage can by converting into absolute paths. What
|
||||
// a terrible tragedy.
|
||||
const compile_unit_dir = blk: {
|
||||
if (comp.zcu) |zcu| m: {
|
||||
const d = try zcu.main_mod.root.joinString(arena, "");
|
||||
if (d.len == 0) break :m;
|
||||
if (std.fs.path.isAbsolute(d)) break :blk d;
|
||||
break :blk std.fs.realpathAlloc(arena, d) catch break :blk d;
|
||||
}
|
||||
break :blk try std.process.getCwdAlloc(arena);
|
||||
};
|
||||
if (!builder.strip) debug_info: {
|
||||
// We fully resolve all paths at this point to avoid lack of
|
||||
// source line info in stack traces or lack of debugging
|
||||
// information which, if relative paths were used, would be
|
||||
// very location dependent.
|
||||
// TODO: the only concern I have with this is WASI as either host or target, should
|
||||
// we leave the paths as relative then?
|
||||
// TODO: This is totally wrong. In dwarf, paths are encoded as relative to
|
||||
// a particular directory, and then the directory path is specified elsewhere.
|
||||
// In the compiler frontend we have it stored correctly in this
|
||||
// way already, but here we throw all that sweet information
|
||||
// into the garbage can by converting into absolute paths. What
|
||||
// a terrible tragedy.
|
||||
const compile_unit_dir = blk: {
|
||||
if (comp.zcu) |zcu| m: {
|
||||
const d = try zcu.main_mod.root.joinString(arena, "");
|
||||
if (d.len == 0) break :m;
|
||||
if (std.fs.path.isAbsolute(d)) break :blk d;
|
||||
break :blk std.fs.realpathAlloc(arena, d) catch break :blk d;
|
||||
}
|
||||
break :blk try std.process.getCwdAlloc(arena);
|
||||
};
|
||||
|
||||
const debug_file = try builder.debugFile(
|
||||
try builder.metadataString(comp.root_name),
|
||||
try builder.metadataString(compile_unit_dir),
|
||||
);
|
||||
const debug_file = try builder.debugFile(
|
||||
try builder.metadataString(comp.root_name),
|
||||
try builder.metadataString(compile_unit_dir),
|
||||
);
|
||||
|
||||
const debug_enums_fwd_ref = try builder.debugForwardReference();
|
||||
const debug_globals_fwd_ref = try builder.debugForwardReference();
|
||||
const debug_enums_fwd_ref = try builder.debugForwardReference();
|
||||
const debug_globals_fwd_ref = try builder.debugForwardReference();
|
||||
|
||||
const debug_compile_unit = try builder.debugCompileUnit(
|
||||
debug_file,
|
||||
// Don't use the version string here; LLVM misparses it when it
|
||||
// includes the git revision.
|
||||
try builder.metadataStringFmt("zig {d}.{d}.{d}", .{
|
||||
build_options.semver.major,
|
||||
build_options.semver.minor,
|
||||
build_options.semver.patch,
|
||||
}),
|
||||
debug_enums_fwd_ref,
|
||||
debug_globals_fwd_ref,
|
||||
.{ .optimized = comp.root_mod.optimize_mode != .Debug },
|
||||
);
|
||||
const debug_compile_unit = try builder.debugCompileUnit(
|
||||
debug_file,
|
||||
// Don't use the version string here; LLVM misparses it when it
|
||||
// includes the git revision.
|
||||
try builder.metadataStringFmt("zig {d}.{d}.{d}", .{
|
||||
build_options.semver.major,
|
||||
build_options.semver.minor,
|
||||
build_options.semver.patch,
|
||||
}),
|
||||
debug_enums_fwd_ref,
|
||||
debug_globals_fwd_ref,
|
||||
.{ .optimized = comp.root_mod.optimize_mode != .Debug },
|
||||
);
|
||||
|
||||
try builder.metadataNamed(try builder.metadataString("llvm.dbg.cu"), &.{debug_compile_unit});
|
||||
break :debug_info .{ debug_compile_unit, debug_enums_fwd_ref, debug_globals_fwd_ref };
|
||||
} else .{.none} ** 3;
|
||||
try builder.metadataNamed(try builder.metadataString("llvm.dbg.cu"), &.{debug_compile_unit});
|
||||
break :debug_info .{ debug_compile_unit, debug_enums_fwd_ref, debug_globals_fwd_ref };
|
||||
} else .{.none} ** 3;
|
||||
|
||||
const obj = try arena.create(Object);
|
||||
obj.* = .{
|
||||
@ -2866,9 +2865,9 @@ pub const Object = struct {
|
||||
|
||||
const full_fields: [2]Builder.Metadata =
|
||||
if (layout.tag_align.compare(.gte, layout.payload_align))
|
||||
.{ debug_tag_type, debug_payload_type }
|
||||
else
|
||||
.{ debug_payload_type, debug_tag_type };
|
||||
.{ debug_tag_type, debug_payload_type }
|
||||
else
|
||||
.{ debug_payload_type, debug_tag_type };
|
||||
|
||||
const debug_tagged_union_type = try o.builder.debugStructType(
|
||||
try o.builder.metadataString(name),
|
||||
@ -4671,11 +4670,11 @@ pub const Object = struct {
|
||||
// instruction is followed by a `wrap_optional`, it will return this value
|
||||
// verbatim, and the result should test as non-null.
|
||||
switch (zcu.getTarget().ptrBitWidth()) {
|
||||
16 => 0xaaaa,
|
||||
32 => 0xaaaaaaaa,
|
||||
64 => 0xaaaaaaaa_aaaaaaaa,
|
||||
else => unreachable,
|
||||
};
|
||||
16 => 0xaaaa,
|
||||
32 => 0xaaaaaaaa,
|
||||
64 => 0xaaaaaaaa_aaaaaaaa,
|
||||
else => unreachable,
|
||||
};
|
||||
const llvm_usize = try o.lowerType(Type.usize);
|
||||
const llvm_ptr_ty = try o.lowerType(ptr_ty);
|
||||
return o.builder.castConst(.inttoptr, try o.builder.intConst(llvm_usize, int), llvm_ptr_ty);
|
||||
@ -9566,7 +9565,7 @@ pub const FuncGen = struct {
|
||||
|
||||
if (llvm_dest_ty.isStruct(&o.builder) or
|
||||
((operand_ty.zigTypeTag(zcu) == .vector or inst_ty.zigTypeTag(zcu) == .vector) and
|
||||
operand_ty.bitSize(zcu) != inst_ty.bitSize(zcu)))
|
||||
operand_ty.bitSize(zcu) != inst_ty.bitSize(zcu)))
|
||||
{
|
||||
// Both our operand and our result are values, not pointers,
|
||||
// but LLVM won't let us bitcast struct values or vectors with padding bits.
|
||||
|
@ -217,20 +217,20 @@ fn initSections(elf_file: *Elf) !void {
|
||||
if (elf_file.section_indexes.eh_frame == null) {
|
||||
elf_file.section_indexes.eh_frame = elf_file.sectionByName(".eh_frame") orelse
|
||||
try elf_file.addSection(.{
|
||||
.name = try elf_file.insertShString(".eh_frame"),
|
||||
.type = if (elf_file.getTarget().cpu.arch == .x86_64)
|
||||
elf.SHT_X86_64_UNWIND
|
||||
else
|
||||
elf.SHT_PROGBITS,
|
||||
.flags = elf.SHF_ALLOC,
|
||||
.addralign = elf_file.ptrWidthBytes(),
|
||||
});
|
||||
.name = try elf_file.insertShString(".eh_frame"),
|
||||
.type = if (elf_file.getTarget().cpu.arch == .x86_64)
|
||||
elf.SHT_X86_64_UNWIND
|
||||
else
|
||||
elf.SHT_PROGBITS,
|
||||
.flags = elf.SHF_ALLOC,
|
||||
.addralign = elf_file.ptrWidthBytes(),
|
||||
});
|
||||
}
|
||||
elf_file.section_indexes.eh_frame_rela = elf_file.sectionByName(".rela.eh_frame") orelse
|
||||
try elf_file.addRelaShdr(
|
||||
try elf_file.insertShString(".rela.eh_frame"),
|
||||
elf_file.section_indexes.eh_frame.?,
|
||||
);
|
||||
try elf_file.insertShString(".rela.eh_frame"),
|
||||
elf_file.section_indexes.eh_frame.?,
|
||||
);
|
||||
}
|
||||
|
||||
try initComdatGroups(elf_file);
|
||||
|
@ -551,7 +551,7 @@ pub const GotSection = struct {
|
||||
switch (entry.tag) {
|
||||
.got => if (symbol.?.flags.import or symbol.?.isIFunc(elf_file) or
|
||||
((elf_file.isEffectivelyDynLib() or (elf_file.base.isExe() and comp.config.pie)) and
|
||||
!symbol.?.isAbs(elf_file)))
|
||||
!symbol.?.isAbs(elf_file)))
|
||||
{
|
||||
num += 1;
|
||||
},
|
||||
|
@ -1580,14 +1580,14 @@ fn initOutputSections(self: *MachO) !void {
|
||||
}
|
||||
self.text_sect_index = self.getSectionByName("__TEXT", "__text") orelse
|
||||
try self.addSection("__TEXT", "__text", .{
|
||||
.alignment = switch (self.getTarget().cpu.arch) {
|
||||
.x86_64 => 0,
|
||||
.aarch64 => 2,
|
||||
else => unreachable,
|
||||
},
|
||||
.flags = macho.S_REGULAR |
|
||||
macho.S_ATTR_PURE_INSTRUCTIONS | macho.S_ATTR_SOME_INSTRUCTIONS,
|
||||
});
|
||||
.alignment = switch (self.getTarget().cpu.arch) {
|
||||
.x86_64 => 0,
|
||||
.aarch64 => 2,
|
||||
else => unreachable,
|
||||
},
|
||||
.flags = macho.S_REGULAR |
|
||||
macho.S_ATTR_PURE_INSTRUCTIONS | macho.S_ATTR_SOME_INSTRUCTIONS,
|
||||
});
|
||||
self.data_sect_index = self.getSectionByName("__DATA", "__data") orelse
|
||||
try self.addSection("__DATA", "__data", .{});
|
||||
}
|
||||
|
@ -149,10 +149,10 @@ pub fn initOutputSection(sect: macho.section_64, macho_file: *MachO) !u8 {
|
||||
if (macho_file.base.isRelocatable()) {
|
||||
const osec = macho_file.getSectionByName(sect.segName(), sect.sectName()) orelse
|
||||
try macho_file.addSection(
|
||||
sect.segName(),
|
||||
sect.sectName(),
|
||||
.{ .flags = sect.flags },
|
||||
);
|
||||
sect.segName(),
|
||||
sect.sectName(),
|
||||
.{ .flags = sect.flags },
|
||||
);
|
||||
return osec;
|
||||
}
|
||||
|
||||
|
@ -1109,8 +1109,8 @@ fn createTlvDescriptor(
|
||||
|
||||
const sect_index = macho_file.getSectionByName("__DATA", "__thread_vars") orelse
|
||||
try macho_file.addSection("__DATA", "__thread_vars", .{
|
||||
.flags = macho.S_THREAD_LOCAL_VARIABLES,
|
||||
});
|
||||
.flags = macho.S_THREAD_LOCAL_VARIABLES,
|
||||
});
|
||||
sym.out_n_sect = sect_index;
|
||||
atom.out_n_sect = sect_index;
|
||||
|
||||
|
@ -102,8 +102,8 @@ fn mark(roots: []*Atom, objects: []const File.Index, macho_file: *MachO) void {
|
||||
const isec = atom.getInputSection(macho_file);
|
||||
if (isec.isDontDeadStripIfReferencesLive() and
|
||||
!(mem.eql(u8, isec.sectName(), "__eh_frame") or
|
||||
mem.eql(u8, isec.sectName(), "__compact_unwind") or
|
||||
isec.attrs() & macho.S_ATTR_DEBUG != 0) and
|
||||
mem.eql(u8, isec.sectName(), "__compact_unwind") or
|
||||
isec.attrs() & macho.S_ATTR_DEBUG != 0) and
|
||||
!atom.isAlive() and refersLive(atom, macho_file))
|
||||
{
|
||||
markLive(atom, macho_file);
|
||||
|
@ -5812,8 +5812,8 @@ pub const ClangArgIterator = struct {
|
||||
|
||||
self.arg_iterator_response_file =
|
||||
initArgIteratorResponseFile(arena, resp_file_path) catch |err| {
|
||||
fatal("unable to read response file '{s}': {s}", .{ resp_file_path, @errorName(err) });
|
||||
};
|
||||
fatal("unable to read response file '{s}': {s}", .{ resp_file_path, @errorName(err) });
|
||||
};
|
||||
// NOTE: The ArgIteratorResponseFile returns tokens from next() that are slices of an
|
||||
// internal buffer. This internal buffer is arena allocated, so it is not cleaned up here.
|
||||
|
||||
@ -6110,8 +6110,8 @@ fn cmdAstCheck(
|
||||
file.tree.tokens.len * (@sizeOf(std.zig.Token.Tag) + @sizeOf(Ast.ByteOffset));
|
||||
const tree_bytes = @sizeOf(Ast) + file.tree.nodes.len *
|
||||
(@sizeOf(Ast.Node.Tag) +
|
||||
@sizeOf(Ast.Node.Data) +
|
||||
@sizeOf(Ast.TokenIndex));
|
||||
@sizeOf(Ast.Node.Data) +
|
||||
@sizeOf(Ast.TokenIndex));
|
||||
const instruction_bytes = file.zir.instructions.len *
|
||||
// Here we don't use @sizeOf(Zir.Inst.Data) because it would include
|
||||
// the debug safety tag but we want to measure release size.
|
||||
|
@ -2569,9 +2569,9 @@ fn transInitListExprRecord(
|
||||
// Unions and Structs are both represented as RecordDecl
|
||||
const record_ty = ty.getAsRecordType() orelse
|
||||
blk: {
|
||||
is_union_type = true;
|
||||
break :blk ty.getAsUnionType();
|
||||
} orelse unreachable;
|
||||
is_union_type = true;
|
||||
break :blk ty.getAsUnionType();
|
||||
} orelse unreachable;
|
||||
const record_decl = record_ty.getDecl();
|
||||
const record_def = record_decl.getDefinition() orelse
|
||||
unreachable;
|
||||
@ -4005,7 +4005,7 @@ fn transCPtrCast(
|
||||
if (!src_ty.isArrayType() and ((src_child_type.isConstQualified() and
|
||||
!child_type.isConstQualified()) or
|
||||
(src_child_type.isVolatileQualified() and
|
||||
!child_type.isVolatileQualified())))
|
||||
!child_type.isVolatileQualified())))
|
||||
{
|
||||
return removeCVQualifiers(c, dst_type_node, expr);
|
||||
} else {
|
||||
@ -4091,8 +4091,8 @@ fn transFloatingLiteralQuad(c: *Context, expr: *const clang.FloatingLiteral, use
|
||||
false;
|
||||
break :fmt_decimal if (could_roundtrip) try c.arena.dupe(u8, temp_str) else null;
|
||||
}
|
||||
// otherwise, fall back to the hexadecimal format
|
||||
orelse try std.fmt.allocPrint(c.arena, "{x}", .{quad});
|
||||
// otherwise, fall back to the hexadecimal format
|
||||
orelse try std.fmt.allocPrint(c.arena, "{x}", .{quad});
|
||||
|
||||
var node = try Tag.float_literal.create(c.arena, str);
|
||||
if (is_negative) node = try Tag.negate.create(c.arena, node);
|
||||
@ -5079,15 +5079,14 @@ fn finishTransFnProto(
|
||||
const is_noalias = param_qt.isRestrictQualified();
|
||||
|
||||
const param_name: ?[]const u8 =
|
||||
if (fn_decl) |decl|
|
||||
blk: {
|
||||
const param = decl.getParamDecl(@as(c_uint, @intCast(i)));
|
||||
const param_name: []const u8 = try c.str(@as(*const clang.NamedDecl, @ptrCast(param)).getName_bytes_begin());
|
||||
if (param_name.len < 1)
|
||||
break :blk null;
|
||||
if (fn_decl) |decl| blk: {
|
||||
const param = decl.getParamDecl(@as(c_uint, @intCast(i)));
|
||||
const param_name: []const u8 = try c.str(@as(*const clang.NamedDecl, @ptrCast(param)).getName_bytes_begin());
|
||||
if (param_name.len < 1)
|
||||
break :blk null;
|
||||
|
||||
break :blk param_name;
|
||||
} else null;
|
||||
break :blk param_name;
|
||||
} else null;
|
||||
const type_node = try transQualType(c, scope, param_qt, source_loc);
|
||||
|
||||
fn_params.addOneAssumeCapacity().* = .{
|
||||
|
@ -50,8 +50,8 @@ test "exporting comptime-known value" {
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64 and
|
||||
(builtin.target.ofmt != .elf and
|
||||
builtin.target.ofmt != .macho and
|
||||
builtin.target.ofmt != .coff)) return error.SkipZigTest;
|
||||
builtin.target.ofmt != .macho and
|
||||
builtin.target.ofmt != .coff)) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
@ -479,7 +479,7 @@ fn testCommentString(b: *Build, opts: Options) *Step {
|
||||
const test_step = addTestStep(b, "comment-string", opts);
|
||||
|
||||
const exe = addExecutable(b, opts, .{ .name = "main", .zig_source_bytes =
|
||||
\\pub fn main() void {}
|
||||
\\pub fn main() void {}
|
||||
});
|
||||
|
||||
const check = exe.checkObject();
|
||||
@ -494,7 +494,7 @@ fn testCommentStringStaticLib(b: *Build, opts: Options) *Step {
|
||||
const test_step = addTestStep(b, "comment-string-static-lib", opts);
|
||||
|
||||
const lib = addStaticLibrary(b, opts, .{ .name = "lib", .zig_source_bytes =
|
||||
\\export fn foo() void {}
|
||||
\\export fn foo() void {}
|
||||
});
|
||||
|
||||
const check = lib.checkObject();
|
||||
@ -865,23 +865,23 @@ fn testEmitRelocatable(b: *Build, opts: Options) *Step {
|
||||
const test_step = addTestStep(b, "emit-relocatable", opts);
|
||||
|
||||
const a_o = addObject(b, opts, .{ .name = "a", .zig_source_bytes =
|
||||
\\const std = @import("std");
|
||||
\\extern var bar: i32;
|
||||
\\export fn foo() i32 {
|
||||
\\ return bar;
|
||||
\\}
|
||||
\\export fn printFoo() void {
|
||||
\\ std.debug.print("foo={d}\n", .{foo()});
|
||||
\\}
|
||||
\\const std = @import("std");
|
||||
\\extern var bar: i32;
|
||||
\\export fn foo() i32 {
|
||||
\\ return bar;
|
||||
\\}
|
||||
\\export fn printFoo() void {
|
||||
\\ std.debug.print("foo={d}\n", .{foo()});
|
||||
\\}
|
||||
});
|
||||
a_o.linkLibC();
|
||||
|
||||
const b_o = addObject(b, opts, .{ .name = "b", .c_source_bytes =
|
||||
\\#include <stdio.h>
|
||||
\\int bar = 42;
|
||||
\\void printBar() {
|
||||
\\ fprintf(stderr, "bar=%d\n", bar);
|
||||
\\}
|
||||
\\#include <stdio.h>
|
||||
\\int bar = 42;
|
||||
\\void printBar() {
|
||||
\\ fprintf(stderr, "bar=%d\n", bar);
|
||||
\\}
|
||||
});
|
||||
b_o.linkLibC();
|
||||
|
||||
@ -890,13 +890,13 @@ fn testEmitRelocatable(b: *Build, opts: Options) *Step {
|
||||
c_o.addObject(b_o);
|
||||
|
||||
const exe = addExecutable(b, opts, .{ .name = "test", .zig_source_bytes =
|
||||
\\const std = @import("std");
|
||||
\\extern fn printFoo() void;
|
||||
\\extern fn printBar() void;
|
||||
\\pub fn main() void {
|
||||
\\ printFoo();
|
||||
\\ printBar();
|
||||
\\}
|
||||
\\const std = @import("std");
|
||||
\\extern fn printFoo() void;
|
||||
\\extern fn printBar() void;
|
||||
\\pub fn main() void {
|
||||
\\ printFoo();
|
||||
\\ printBar();
|
||||
\\}
|
||||
});
|
||||
exe.addObject(c_o);
|
||||
exe.linkLibC();
|
||||
@ -1924,8 +1924,8 @@ fn testInitArrayOrder(b: *Build, opts: Options) *Step {
|
||||
g_o.linkLibC();
|
||||
|
||||
const h_o = addObject(b, opts, .{ .name = "h", .c_source_bytes =
|
||||
\\#include <stdio.h>
|
||||
\\__attribute__((destructor)) void fini2() { printf("8"); }
|
||||
\\#include <stdio.h>
|
||||
\\__attribute__((destructor)) void fini2() { printf("8"); }
|
||||
});
|
||||
h_o.linkLibC();
|
||||
|
||||
@ -2488,23 +2488,23 @@ fn testMergeStrings2(b: *Build, opts: Options) *Step {
|
||||
const test_step = addTestStep(b, "merge-strings2", opts);
|
||||
|
||||
const obj1 = addObject(b, opts, .{ .name = "a", .zig_source_bytes =
|
||||
\\const std = @import("std");
|
||||
\\export fn foo() void {
|
||||
\\ var arr: [5:0]u16 = [_:0]u16{ 1, 2, 3, 4, 5 };
|
||||
\\ const slice = std.mem.sliceTo(&arr, 3);
|
||||
\\ std.testing.expectEqualSlices(u16, arr[0..2], slice) catch unreachable;
|
||||
\\}
|
||||
\\const std = @import("std");
|
||||
\\export fn foo() void {
|
||||
\\ var arr: [5:0]u16 = [_:0]u16{ 1, 2, 3, 4, 5 };
|
||||
\\ const slice = std.mem.sliceTo(&arr, 3);
|
||||
\\ std.testing.expectEqualSlices(u16, arr[0..2], slice) catch unreachable;
|
||||
\\}
|
||||
});
|
||||
|
||||
const obj2 = addObject(b, opts, .{ .name = "b", .zig_source_bytes =
|
||||
\\const std = @import("std");
|
||||
\\extern fn foo() void;
|
||||
\\pub fn main() void {
|
||||
\\ foo();
|
||||
\\ var arr: [5:0]u16 = [_:0]u16{ 5, 4, 3, 2, 1 };
|
||||
\\ const slice = std.mem.sliceTo(&arr, 3);
|
||||
\\ std.testing.expectEqualSlices(u16, arr[0..2], slice) catch unreachable;
|
||||
\\}
|
||||
\\const std = @import("std");
|
||||
\\extern fn foo() void;
|
||||
\\pub fn main() void {
|
||||
\\ foo();
|
||||
\\ var arr: [5:0]u16 = [_:0]u16{ 5, 4, 3, 2, 1 };
|
||||
\\ const slice = std.mem.sliceTo(&arr, 3);
|
||||
\\ std.testing.expectEqualSlices(u16, arr[0..2], slice) catch unreachable;
|
||||
\\}
|
||||
});
|
||||
|
||||
{
|
||||
@ -2745,17 +2745,17 @@ fn testRelocatableEhFrame(b: *Build, opts: Options) *Step {
|
||||
});
|
||||
obj2.linkLibCpp();
|
||||
const obj3 = addObject(b, opts, .{ .name = "obj3", .cpp_source_bytes =
|
||||
\\#include <iostream>
|
||||
\\#include <stdexcept>
|
||||
\\extern int try_again();
|
||||
\\int main() {
|
||||
\\ try {
|
||||
\\ try_again();
|
||||
\\ } catch (const std::exception &e) {
|
||||
\\ std::cout << "exception=" << e.what();
|
||||
\\ }
|
||||
\\ return 0;
|
||||
\\}
|
||||
\\#include <iostream>
|
||||
\\#include <stdexcept>
|
||||
\\extern int try_again();
|
||||
\\int main() {
|
||||
\\ try {
|
||||
\\ try_again();
|
||||
\\ } catch (const std::exception &e) {
|
||||
\\ std::cout << "exception=" << e.what();
|
||||
\\ }
|
||||
\\ return 0;
|
||||
\\}
|
||||
});
|
||||
obj3.linkLibCpp();
|
||||
|
||||
@ -2857,15 +2857,15 @@ fn testRelocatableMergeStrings(b: *Build, opts: Options) *Step {
|
||||
const test_step = addTestStep(b, "relocatable-merge-strings", opts);
|
||||
|
||||
const obj1 = addObject(b, opts, .{ .name = "a", .asm_source_bytes =
|
||||
\\.section .rodata.str1.1,"aMS",@progbits,1
|
||||
\\val1:
|
||||
\\.ascii "Hello \0"
|
||||
\\.section .rodata.str1.1,"aMS",@progbits,1
|
||||
\\val5:
|
||||
\\.ascii "World \0"
|
||||
\\.section .rodata.str1.1,"aMS",@progbits,1
|
||||
\\val7:
|
||||
\\.ascii "Hello \0"
|
||||
\\.section .rodata.str1.1,"aMS",@progbits,1
|
||||
\\val1:
|
||||
\\.ascii "Hello \0"
|
||||
\\.section .rodata.str1.1,"aMS",@progbits,1
|
||||
\\val5:
|
||||
\\.ascii "World \0"
|
||||
\\.section .rodata.str1.1,"aMS",@progbits,1
|
||||
\\val7:
|
||||
\\.ascii "Hello \0"
|
||||
});
|
||||
|
||||
const obj2 = addObject(b, opts, .{ .name = "b" });
|
||||
@ -3023,18 +3023,18 @@ fn testThunks(b: *Build, opts: Options) *Step {
|
||||
const test_step = addTestStep(b, "thunks", opts);
|
||||
|
||||
const exe = addExecutable(b, opts, .{ .name = "main", .c_source_bytes =
|
||||
\\void foo();
|
||||
\\__attribute__((section(".bar"))) void bar() {
|
||||
\\ return foo();
|
||||
\\}
|
||||
\\__attribute__((section(".foo"))) void foo() {
|
||||
\\ return bar();
|
||||
\\}
|
||||
\\int main() {
|
||||
\\ foo();
|
||||
\\ bar();
|
||||
\\ return 0;
|
||||
\\}
|
||||
\\void foo();
|
||||
\\__attribute__((section(".bar"))) void bar() {
|
||||
\\ return foo();
|
||||
\\}
|
||||
\\__attribute__((section(".foo"))) void foo() {
|
||||
\\ return bar();
|
||||
\\}
|
||||
\\int main() {
|
||||
\\ foo();
|
||||
\\ bar();
|
||||
\\ return 0;
|
||||
\\}
|
||||
});
|
||||
|
||||
const check = exe.checkObject();
|
||||
|
1624
test/link/macho.zig
1624
test/link/macho.zig
File diff suppressed because it is too large
Load Diff
@ -203,7 +203,7 @@ fn printOutput(
|
||||
if (mem.startsWith(u8, triple, "wasm32") or
|
||||
mem.startsWith(u8, triple, "riscv64-linux") or
|
||||
(mem.startsWith(u8, triple, "x86_64-linux") and
|
||||
builtin.os.tag != .linux or builtin.cpu.arch != .x86_64))
|
||||
builtin.os.tag != .linux or builtin.cpu.arch != .x86_64))
|
||||
{
|
||||
// skip execution
|
||||
break :code_block;
|
||||
|
@ -753,7 +753,7 @@ pub fn main() anyerror!void {
|
||||
if ((std.mem.startsWith(u8, name, "mno-") and
|
||||
llvm_to_zig_cpu_features.contains(name["mno-".len..])) or
|
||||
(std.mem.startsWith(u8, name, "m") and
|
||||
llvm_to_zig_cpu_features.contains(name["m".len..])))
|
||||
llvm_to_zig_cpu_features.contains(name["m".len..])))
|
||||
{
|
||||
try stdout.print("m(\"{s}\"),\n", .{name});
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user