Skip to content

Commit 7ef9071

Browse files
authored
Merge branch 'master' into zon-stop-on-node
2 parents 73c2551 + 8957b27 commit 7ef9071

File tree

762 files changed

+29076
-11291
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

762 files changed

+29076
-11291
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ set(ZIG_STAGE2_SOURCES
559559
src/arch/x86_64/abi.zig
560560
src/arch/x86_64/bits.zig
561561
src/arch/x86_64/encoder.zig
562-
src/arch/x86_64/encodings.zig
562+
src/arch/x86_64/encodings.zon
563563
src/clang.zig
564564
src/clang_options.zig
565565
src/clang_options_data.zig

doc/langref.html.in

Lines changed: 221 additions & 59 deletions
Large diffs are not rendered by default.

doc/langref/TopLevelFields.zig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//! Because this file contains fields, it is a type which is intended to be instantiated, and so
2+
//! is named in TitleCase instead of snake_case by convention.
3+
4+
foo: u32,
5+
bar: u64,
6+
7+
/// `@This()` can be used to refer to this struct type. In files with fields, it is quite common to
8+
/// name the type here, so it can be easily referenced by other declarations in this file.
9+
const TopLevelFields = @This();
10+
11+
pub fn init(val: u32) TopLevelFields {
12+
return .{
13+
.foo = val,
14+
.bar = val * 10,
15+
};
16+
}
17+
18+
// syntax

doc/langref/entry_point.zig

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/// `std.start` imports this file using `@import("root")`, and uses this declaration as the program's
2+
/// user-provided entry point. It can return any of the following types:
3+
/// * `void`
4+
/// * `E!void`, for any error set `E`
5+
/// * `u8`
6+
/// * `E!u8`, for any error set `E`
7+
/// Returning a `void` value from this function will exit with code 0.
8+
/// Returning a `u8` value from this function will exit with the given status code.
9+
/// Returning an error value from this function will print an Error Return Trace and exit with code 1.
10+
pub fn main() void {
11+
std.debug.print("Hello, World!\n", .{});
12+
}
13+
14+
// If uncommented, this declaration would suppress the usual std.start logic, causing
15+
// the `main` declaration above to be ignored.
16+
//pub const _start = {};
17+
18+
const std = @import("std");
19+
20+
// exe=succeed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
pub export fn main(argc: c_int, argv: [*]const [*:0]const u8) c_int {
2+
const args = argv[0..@intCast(argc)];
3+
std.debug.print("Hello! argv[0] is '{s}'\n", .{args[0]});
4+
return 0;
5+
}
6+
7+
const std = @import("std");
8+
9+
// exe=succeed
10+
// link_libc

doc/langref/panic_handler.zig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
pub fn main() void {
2+
@setRuntimeSafety(true);
3+
var x: u8 = 255;
4+
// Let's overflow this integer!
5+
x += 1;
6+
}
7+
8+
pub const panic = std.debug.FullPanic(myPanic);
9+
10+
fn myPanic(msg: []const u8, first_trace_addr: ?usize) noreturn {
11+
_ = first_trace_addr;
12+
std.debug.print("Panic! {s}\n", .{msg});
13+
std.process.exit(1);
14+
}
15+
16+
const std = @import("std");
17+
18+
// exe=fail

doc/langref/std_options.zig

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/// The presence of this declaration allows the program to override certain behaviors of the standard library.
2+
/// For a full list of available options, see the documentation for `std.Options`.
3+
pub const std_options: std.Options = .{
4+
// By default, in safe build modes, the standard library will attach a segfault handler to the program to
5+
// print a helpful stack trace if a segmentation fault occurs. Here, we can disable this, or even enable
6+
// it in unsafe build modes.
7+
.enable_segfault_handler = true,
8+
// This is the logging function used by `std.log`.
9+
.logFn = myLogFn,
10+
};
11+
12+
fn myLogFn(
13+
comptime level: std.log.Level,
14+
comptime scope: @Type(.enum_literal),
15+
comptime format: []const u8,
16+
args: anytype,
17+
) void {
18+
// We could do anything we want here!
19+
// ...but actually, let's just call the default implementation.
20+
std.log.defaultLog(level, scope, format, args);
21+
}
22+
23+
const std = @import("std");
24+
25+
// syntax

doc/langref/test_setRuntimeSafety_builtin.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ test "@setRuntimeSafety" {
22
// The builtin applies to the scope that it is called in. So here, integer overflow
33
// will not be caught in ReleaseFast and ReleaseSmall modes:
44
// var x: u8 = 255;
5-
// x += 1; // undefined behavior in ReleaseFast/ReleaseSmall modes.
5+
// x += 1; // Unchecked Illegal Behavior in ReleaseFast/ReleaseSmall modes.
66
{
77
// However this block has safety enabled, so safety checks happen here,
88
// even in ReleaseFast and ReleaseSmall modes.
@@ -15,7 +15,7 @@ test "@setRuntimeSafety" {
1515
// would not be caught in any build mode.
1616
@setRuntimeSafety(false);
1717
// var x: u8 = 255;
18-
// x += 1; // undefined behavior in all build modes.
18+
// x += 1; // Unchecked Illegal Behavior in all build modes.
1919
}
2020
}
2121
}

lib/compiler/aro/aro/Parser.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,7 @@ fn decl(p: *Parser) Error!bool {
979979
_ = try p.expectToken(.semicolon);
980980
if (decl_spec.ty.is(.@"enum") or
981981
(decl_spec.ty.isRecord() and !decl_spec.ty.isAnonymousRecord(p.comp) and
982-
!decl_spec.ty.isTypeof())) // we follow GCC and clang's behavior here
982+
!decl_spec.ty.isTypeof())) // we follow GCC and clang's behavior here
983983
{
984984
const specifier = decl_spec.ty.canonicalize(.standard).specifier;
985985
const attrs = p.attr_buf.items(.attr)[attr_buf_top..];

lib/compiler/aro/aro/pragmas/gcc.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ fn preprocessorHandler(pragma: *Pragma, pp: *Preprocessor, start_idx: TokenIndex
114114

115115
const gcc_pragma = std.meta.stringToEnum(Directive, pp.expandedSlice(directive_tok)) orelse
116116
return pp.comp.addDiagnostic(.{
117-
.tag = .unknown_gcc_pragma,
118-
.loc = directive_tok.loc,
119-
}, pp.expansionSlice(start_idx + 1));
117+
.tag = .unknown_gcc_pragma,
118+
.loc = directive_tok.loc,
119+
}, pp.expansionSlice(start_idx + 1));
120120

121121
switch (gcc_pragma) {
122122
.warning, .@"error" => {

0 commit comments

Comments
 (0)