parser: port pointer/slice attributes tests
Port tests: - "pointer attributes" - "slice attributes" Fix ** pointer type to parse modifiers per upstream (no sentinel, modifiers on inner pointer only). Fix ptr_type selection when both sentinel and align are present (use ptr_type with extra data instead of ptr_type_sentinel which can't store alignment). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2850,6 +2850,28 @@ test "zig fmt: nested pointers with ** tokens" {
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: pointer attributes" {
|
||||
try testCanonical(
|
||||
\\extern fn f1(s: *align(*u8) u8) c_int;
|
||||
\\extern fn f2(s: **align(1) *const *volatile u8) c_int;
|
||||
\\extern fn f3(s: *align(1) const *align(1) volatile *const volatile u8) c_int;
|
||||
\\extern fn f4(s: *align(1) const volatile u8) c_int;
|
||||
\\extern fn f5(s: [*:0]align(1) const volatile u8) c_int;
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: slice attributes" {
|
||||
try testCanonical(
|
||||
\\extern fn f1(s: []align(*u8) u8) c_int;
|
||||
\\extern fn f2(s: []align(1) []const []volatile u8) c_int;
|
||||
\\extern fn f3(s: []align(1) const [:0]align(1) volatile []const volatile u8) c_int;
|
||||
\\extern fn f4(s: []align(1) const volatile u8) c_int;
|
||||
\\extern fn f5(s: [:0]align(1) const volatile u8) c_int;
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: test declaration" {
|
||||
try testCanonical(
|
||||
\\test "test name" {
|
||||
@@ -5550,5 +5572,3 @@ fn zigAst(gpa: Allocator, c_ast: c.Ast) !Ast {
|
||||
.errors = errors,
|
||||
};
|
||||
}
|
||||
|
||||
// copy-past from parser_test.zig
|
||||
|
||||
Reference in New Issue
Block a user