Merge remote-tracking branch 'origin/master' into llvm9
This commit is contained in:
@@ -306,6 +306,8 @@ pub fn Channel(comptime T: type) type {
|
||||
test "std.event.Channel" {
|
||||
// https://github.com/ziglang/zig/issues/1908
|
||||
if (builtin.single_threaded) return error.SkipZigTest;
|
||||
// https://github.com/ziglang/zig/issues/3251
|
||||
if (std.os.freebsd.is_the_target) return error.SkipZigTest;
|
||||
|
||||
var loop: Loop = undefined;
|
||||
// TODO make a multi threaded test
|
||||
|
||||
@@ -85,6 +85,8 @@ pub fn Future(comptime T: type) type {
|
||||
test "std.event.Future" {
|
||||
// https://github.com/ziglang/zig/issues/1908
|
||||
if (builtin.single_threaded) return error.SkipZigTest;
|
||||
// https://github.com/ziglang/zig/issues/3251
|
||||
if (std.os.freebsd.is_the_target) return error.SkipZigTest;
|
||||
|
||||
const allocator = std.heap.direct_allocator;
|
||||
|
||||
|
||||
@@ -118,6 +118,8 @@ pub const Lock = struct {
|
||||
test "std.event.Lock" {
|
||||
// TODO https://github.com/ziglang/zig/issues/1908
|
||||
if (builtin.single_threaded) return error.SkipZigTest;
|
||||
// TODO https://github.com/ziglang/zig/issues/3251
|
||||
if (std.os.freebsd.is_the_target) return error.SkipZigTest;
|
||||
|
||||
const allocator = std.heap.direct_allocator;
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ pub fn hash(hasher: var, key: var, comptime strat: HashStrategy) void {
|
||||
// Otherwise, hash every element.
|
||||
// TODO remove the copy to an array once field access is done.
|
||||
const array: [info.len]info.child = key;
|
||||
comptime var i: u32 = 0;
|
||||
comptime var i = 0;
|
||||
inline while (i < info.len) : (i += 1) {
|
||||
hash(hasher, array[i], strat);
|
||||
}
|
||||
@@ -357,10 +357,13 @@ test "testHash union" {
|
||||
test "testHash vector" {
|
||||
const a: @Vector(4, u32) = [_]u32{ 1, 2, 3, 4 };
|
||||
const b: @Vector(4, u32) = [_]u32{ 1, 2, 3, 5 };
|
||||
const c: @Vector(4, u31) = [_]u31{ 1, 2, 3, 4 };
|
||||
testing.expect(testHash(a) == testHash(a));
|
||||
testing.expect(testHash(a) != testHash(b));
|
||||
testing.expect(testHash(a) != testHash(c));
|
||||
|
||||
const c: @Vector(4, u31) = [_]u31{ 1, 2, 3, 4 };
|
||||
const d: @Vector(4, u31) = [_]u31{ 1, 2, 3, 5 };
|
||||
testing.expect(testHash(c) == testHash(c));
|
||||
testing.expect(testHash(c) != testHash(d));
|
||||
}
|
||||
|
||||
test "testHash error union" {
|
||||
|
||||
@@ -299,7 +299,7 @@ pub const Headers = struct {
|
||||
return buf;
|
||||
}
|
||||
|
||||
/// Returns all headers with the given name as a comma seperated string.
|
||||
/// Returns all headers with the given name as a comma separated string.
|
||||
///
|
||||
/// Useful for HTTP headers that follow RFC-7230 section 3.2.2:
|
||||
/// A recipient MAY combine multiple header fields with the same field
|
||||
|
||||
@@ -269,16 +269,11 @@ nakedcc fn clone() void {
|
||||
\\ bx lr
|
||||
\\
|
||||
\\1: mov r0,r6
|
||||
\\ tst r5,#1
|
||||
\\ bne 1f
|
||||
\\ mov lr,pc
|
||||
\\ mov pc,r5
|
||||
\\ bl 3f
|
||||
\\2: mov r7,#1
|
||||
\\ svc 0
|
||||
\\
|
||||
\\1: mov lr,pc
|
||||
\\ bx r5
|
||||
\\ b 2b
|
||||
\\3: bx r5
|
||||
);
|
||||
} else {
|
||||
@compileError("Implement clone() for this arch.");
|
||||
|
||||
@@ -23,7 +23,7 @@ comptime {
|
||||
} else if (builtin.os == .uefi) {
|
||||
@export("EfiMain", EfiMain, .Strong);
|
||||
} else {
|
||||
@export("_start", _start, .Strong);
|
||||
if (!@hasDecl(root, "_start")) @export("_start", _start, .Strong);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -255,39 +255,39 @@ pub const Error = union(enum) {
|
||||
}
|
||||
}
|
||||
|
||||
pub const InvalidToken = SingleTokenError("Invalid token {}");
|
||||
pub const ExpectedContainerMembers = SingleTokenError("Expected test, comptime, var decl, or container field, found {}");
|
||||
pub const ExpectedStringLiteral = SingleTokenError("Expected string literal, found {}");
|
||||
pub const ExpectedIntegerLiteral = SingleTokenError("Expected integer literal, found {}");
|
||||
pub const ExpectedIdentifier = SingleTokenError("Expected identifier, found {}");
|
||||
pub const ExpectedStatement = SingleTokenError("Expected statement, found {}");
|
||||
pub const ExpectedVarDeclOrFn = SingleTokenError("Expected variable declaration or function, found {}");
|
||||
pub const ExpectedVarDecl = SingleTokenError("Expected variable declaration, found {}");
|
||||
pub const ExpectedReturnType = SingleTokenError("Expected 'var' or return type expression, found {}");
|
||||
pub const ExpectedAggregateKw = SingleTokenError("Expected " ++ @tagName(Token.Id.Keyword_struct) ++ ", " ++ @tagName(Token.Id.Keyword_union) ++ ", or " ++ @tagName(Token.Id.Keyword_enum) ++ ", found {}");
|
||||
pub const ExpectedEqOrSemi = SingleTokenError("Expected '=' or ';', found {}");
|
||||
pub const ExpectedSemiOrLBrace = SingleTokenError("Expected ';' or '{{', found {}");
|
||||
pub const ExpectedSemiOrElse = SingleTokenError("Expected ';' or 'else', found {}");
|
||||
pub const ExpectedLBrace = SingleTokenError("Expected '{{', found {}");
|
||||
pub const ExpectedLabelOrLBrace = SingleTokenError("Expected label or '{{', found {}");
|
||||
pub const ExpectedColonOrRParen = SingleTokenError("Expected ':' or ')', found {}");
|
||||
pub const ExpectedLabelable = SingleTokenError("Expected 'while', 'for', 'inline', 'suspend', or '{{', found {}");
|
||||
pub const ExpectedInlinable = SingleTokenError("Expected 'while' or 'for', found {}");
|
||||
pub const ExpectedAsmOutputReturnOrType = SingleTokenError("Expected '->' or " ++ @tagName(Token.Id.Identifier) ++ ", found {}");
|
||||
pub const ExpectedSliceOrRBracket = SingleTokenError("Expected ']' or '..', found {}");
|
||||
pub const ExpectedTypeExpr = SingleTokenError("Expected type expression, found {}");
|
||||
pub const ExpectedPrimaryTypeExpr = SingleTokenError("Expected primary type expression, found {}");
|
||||
pub const ExpectedExpr = SingleTokenError("Expected expression, found {}");
|
||||
pub const ExpectedPrimaryExpr = SingleTokenError("Expected primary expression, found {}");
|
||||
pub const ExpectedParamList = SingleTokenError("Expected parameter list, found {}");
|
||||
pub const ExpectedPayload = SingleTokenError("Expected loop payload, found {}");
|
||||
pub const ExpectedBlockOrAssignment = SingleTokenError("Expected block or assignment, found {}");
|
||||
pub const ExpectedBlockOrExpression = SingleTokenError("Expected block or expression, found {}");
|
||||
pub const ExpectedExprOrAssignment = SingleTokenError("Expected expression or assignment, found {}");
|
||||
pub const ExpectedPrefixExpr = SingleTokenError("Expected prefix expression, found {}");
|
||||
pub const ExpectedLoopExpr = SingleTokenError("Expected loop expression, found {}");
|
||||
pub const ExpectedDerefOrUnwrap = SingleTokenError("Expected pointer dereference or optional unwrap, found {}");
|
||||
pub const ExpectedSuffixOp = SingleTokenError("Expected pointer dereference, optional unwrap, or field access, found {}");
|
||||
pub const InvalidToken = SingleTokenError("Invalid token '{}'");
|
||||
pub const ExpectedContainerMembers = SingleTokenError("Expected test, comptime, var decl, or container field, found '{}'");
|
||||
pub const ExpectedStringLiteral = SingleTokenError("Expected string literal, found '{}'");
|
||||
pub const ExpectedIntegerLiteral = SingleTokenError("Expected integer literal, found '{}'");
|
||||
pub const ExpectedIdentifier = SingleTokenError("Expected identifier, found '{}'");
|
||||
pub const ExpectedStatement = SingleTokenError("Expected statement, found '{}'");
|
||||
pub const ExpectedVarDeclOrFn = SingleTokenError("Expected variable declaration or function, found '{}'");
|
||||
pub const ExpectedVarDecl = SingleTokenError("Expected variable declaration, found '{}'");
|
||||
pub const ExpectedReturnType = SingleTokenError("Expected 'var' or return type expression, found '{}'");
|
||||
pub const ExpectedAggregateKw = SingleTokenError("Expected '" ++ Token.Id.Keyword_struct.symbol() ++ "', '" ++ Token.Id.Keyword_union.symbol() ++ "', or '" ++ Token.Id.Keyword_enum.symbol() ++ "', found '{}'");
|
||||
pub const ExpectedEqOrSemi = SingleTokenError("Expected '=' or ';', found '{}'");
|
||||
pub const ExpectedSemiOrLBrace = SingleTokenError("Expected ';' or '{{', found '{}'");
|
||||
pub const ExpectedSemiOrElse = SingleTokenError("Expected ';' or 'else', found '{}'");
|
||||
pub const ExpectedLBrace = SingleTokenError("Expected '{{', found '{}'");
|
||||
pub const ExpectedLabelOrLBrace = SingleTokenError("Expected label or '{{', found '{}'");
|
||||
pub const ExpectedColonOrRParen = SingleTokenError("Expected ':' or ')', found '{}'");
|
||||
pub const ExpectedLabelable = SingleTokenError("Expected 'while', 'for', 'inline', 'suspend', or '{{', found '{}'");
|
||||
pub const ExpectedInlinable = SingleTokenError("Expected 'while' or 'for', found '{}'");
|
||||
pub const ExpectedAsmOutputReturnOrType = SingleTokenError("Expected '->' or '" ++ Token.Id.Identifier.symbol() ++ "', found '{}'");
|
||||
pub const ExpectedSliceOrRBracket = SingleTokenError("Expected ']' or '..', found '{}'");
|
||||
pub const ExpectedTypeExpr = SingleTokenError("Expected type expression, found '{}'");
|
||||
pub const ExpectedPrimaryTypeExpr = SingleTokenError("Expected primary type expression, found '{}'");
|
||||
pub const ExpectedExpr = SingleTokenError("Expected expression, found '{}'");
|
||||
pub const ExpectedPrimaryExpr = SingleTokenError("Expected primary expression, found '{}'");
|
||||
pub const ExpectedParamList = SingleTokenError("Expected parameter list, found '{}'");
|
||||
pub const ExpectedPayload = SingleTokenError("Expected loop payload, found '{}'");
|
||||
pub const ExpectedBlockOrAssignment = SingleTokenError("Expected block or assignment, found '{}'");
|
||||
pub const ExpectedBlockOrExpression = SingleTokenError("Expected block or expression, found '{}'");
|
||||
pub const ExpectedExprOrAssignment = SingleTokenError("Expected expression or assignment, found '{}'");
|
||||
pub const ExpectedPrefixExpr = SingleTokenError("Expected prefix expression, found '{}'");
|
||||
pub const ExpectedLoopExpr = SingleTokenError("Expected loop expression, found '{}'");
|
||||
pub const ExpectedDerefOrUnwrap = SingleTokenError("Expected pointer dereference or optional unwrap, found '{}'");
|
||||
pub const ExpectedSuffixOp = SingleTokenError("Expected pointer dereference, optional unwrap, or field access, found '{}'");
|
||||
|
||||
pub const ExpectedParamType = SimpleError("Expected parameter type");
|
||||
pub const ExpectedPubItem = SimpleError("Pub must be followed by fn decl, var decl, or container member");
|
||||
@@ -324,11 +324,11 @@ pub const Error = union(enum) {
|
||||
return stream.print("`&&` is invalid. Note that `and` is boolean AND.");
|
||||
},
|
||||
.Invalid => {
|
||||
return stream.print("expected {}, found invalid bytes", @tagName(self.expected_id));
|
||||
return stream.print("expected '{}', found invalid bytes", self.expected_id.symbol());
|
||||
},
|
||||
else => {
|
||||
const token_name = @tagName(found_token.id);
|
||||
return stream.print("expected {}, found {}", @tagName(self.expected_id), token_name);
|
||||
const token_name = found_token.id.symbol();
|
||||
return stream.print("expected '{}', found '{}'", self.expected_id.symbol(), token_name);
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -339,8 +339,8 @@ pub const Error = union(enum) {
|
||||
end_id: Token.Id,
|
||||
|
||||
pub fn render(self: *const ExpectedCommaOrEnd, tokens: *Tree.TokenList, stream: var) !void {
|
||||
const token_name = @tagName(tokens.at(self.token).id);
|
||||
return stream.print("expected ',' or {}, found {}", @tagName(self.end_id), token_name);
|
||||
const actual_token = tokens.at(self.token);
|
||||
return stream.print("expected ',' or '{}', found '{}'", self.end_id.symbol(), actual_token.id.symbol());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -351,8 +351,8 @@ pub const Error = union(enum) {
|
||||
token: TokenIndex,
|
||||
|
||||
pub fn render(self: *const ThisError, tokens: *Tree.TokenList, stream: var) !void {
|
||||
const token_name = @tagName(tokens.at(self.token).id);
|
||||
return stream.print(msg, token_name);
|
||||
const actual_token = tokens.at(self.token);
|
||||
return stream.print(msg, actual_token.id.symbol());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -196,6 +196,131 @@ pub const Token = struct {
|
||||
Keyword_var,
|
||||
Keyword_volatile,
|
||||
Keyword_while,
|
||||
|
||||
pub fn symbol(id: Id) []const u8 {
|
||||
return switch (id) {
|
||||
.Invalid => "Invalid",
|
||||
.Invalid_ampersands => "&&",
|
||||
.Identifier => "Identifier",
|
||||
.StringLiteral => "StringLiteral",
|
||||
.MultilineStringLiteralLine => "MultilineStringLiteralLine",
|
||||
.CharLiteral => "CharLiteral",
|
||||
.Eof => "Eof",
|
||||
.Builtin => "Builtin",
|
||||
.IntegerLiteral => "IntegerLiteral",
|
||||
.FloatLiteral => "FloatLiteral",
|
||||
.LineComment => "LineComment",
|
||||
.DocComment => "DocComment",
|
||||
.ShebangLine => "ShebangLine",
|
||||
|
||||
.Bang => "!",
|
||||
.Pipe => "|",
|
||||
.PipePipe => "||",
|
||||
.PipeEqual => "|=",
|
||||
.Equal => "=",
|
||||
.EqualEqual => "==",
|
||||
.EqualAngleBracketRight => "=>",
|
||||
.BangEqual => "!=",
|
||||
.LParen => "(",
|
||||
.RParen => ")",
|
||||
.Semicolon => ";",
|
||||
.Percent => "%",
|
||||
.PercentEqual => "%=",
|
||||
.LBrace => "{",
|
||||
.RBrace => "}",
|
||||
.LBracket => "[",
|
||||
.RBracket => "]",
|
||||
.Period => ".",
|
||||
.Ellipsis2 => "..",
|
||||
.Ellipsis3 => "...",
|
||||
.Caret => "^",
|
||||
.CaretEqual => "^=",
|
||||
.Plus => "+",
|
||||
.PlusPlus => "++",
|
||||
.PlusEqual => "+=",
|
||||
.PlusPercent => "+%",
|
||||
.PlusPercentEqual => "+%=",
|
||||
.Minus => "-",
|
||||
.MinusEqual => "-=",
|
||||
.MinusPercent => "-%",
|
||||
.MinusPercentEqual => "-%=",
|
||||
.Asterisk => "*",
|
||||
.AsteriskEqual => "*=",
|
||||
.AsteriskAsterisk => "**",
|
||||
.AsteriskPercent => "*%",
|
||||
.AsteriskPercentEqual => "*%=",
|
||||
.Arrow => "->",
|
||||
.Colon => ":",
|
||||
.Slash => "/",
|
||||
.SlashEqual => "/=",
|
||||
.Comma => ",",
|
||||
.Ampersand => "&",
|
||||
.AmpersandEqual => "&=",
|
||||
.QuestionMark => "?",
|
||||
.AngleBracketLeft => "<",
|
||||
.AngleBracketLeftEqual => "<=",
|
||||
.AngleBracketAngleBracketLeft => "<<",
|
||||
.AngleBracketAngleBracketLeftEqual => "<<=",
|
||||
.AngleBracketRight => ">",
|
||||
.AngleBracketRightEqual => ">=",
|
||||
.AngleBracketAngleBracketRight => ">>",
|
||||
.AngleBracketAngleBracketRightEqual => ">>=",
|
||||
.Tilde => "~",
|
||||
.BracketStarBracket => "[*]",
|
||||
.BracketStarCBracket => "[*c]",
|
||||
.Keyword_align => "align",
|
||||
.Keyword_allowzero => "allowzero",
|
||||
.Keyword_and => "and",
|
||||
.Keyword_anyframe => "anyframe",
|
||||
.Keyword_asm => "asm",
|
||||
.Keyword_async => "async",
|
||||
.Keyword_await => "await",
|
||||
.Keyword_break => "break",
|
||||
.Keyword_catch => "catch",
|
||||
.Keyword_comptime => "comptime",
|
||||
.Keyword_const => "const",
|
||||
.Keyword_continue => "continue",
|
||||
.Keyword_defer => "defer",
|
||||
.Keyword_else => "else",
|
||||
.Keyword_enum => "enum",
|
||||
.Keyword_errdefer => "errdefer",
|
||||
.Keyword_error => "error",
|
||||
.Keyword_export => "export",
|
||||
.Keyword_extern => "extern",
|
||||
.Keyword_false => "false",
|
||||
.Keyword_fn => "fn",
|
||||
.Keyword_for => "for",
|
||||
.Keyword_if => "if",
|
||||
.Keyword_inline => "inline",
|
||||
.Keyword_nakedcc => "nakedcc",
|
||||
.Keyword_noalias => "noalias",
|
||||
.Keyword_noasync => "noasync",
|
||||
.Keyword_noinline => "noinline",
|
||||
.Keyword_null => "null",
|
||||
.Keyword_or => "or",
|
||||
.Keyword_orelse => "orelse",
|
||||
.Keyword_packed => "packed",
|
||||
.Keyword_pub => "pub",
|
||||
.Keyword_resume => "resume",
|
||||
.Keyword_return => "return",
|
||||
.Keyword_linksection => "linksection",
|
||||
.Keyword_stdcallcc => "stdcallcc",
|
||||
.Keyword_struct => "struct",
|
||||
.Keyword_suspend => "suspend",
|
||||
.Keyword_switch => "switch",
|
||||
.Keyword_test => "test",
|
||||
.Keyword_threadlocal => "threadlocal",
|
||||
.Keyword_true => "true",
|
||||
.Keyword_try => "try",
|
||||
.Keyword_undefined => "undefined",
|
||||
.Keyword_union => "union",
|
||||
.Keyword_unreachable => "unreachable",
|
||||
.Keyword_usingnamespace => "usingnamespace",
|
||||
.Keyword_var => "var",
|
||||
.Keyword_volatile => "volatile",
|
||||
.Keyword_while => "while",
|
||||
};
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user