-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
compiler: Disallow align(0) everywhere in the language.
Thus leaving the design space for this alignment value open, e.g. for packing.
- Loading branch information
Showing
3 changed files
with
57 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
pub var global_var: i32 align(0) = undefined; | ||
|
||
pub export fn a() void { | ||
_ = &global_var; | ||
} | ||
|
||
pub extern var extern_var: i32 align(0); | ||
|
||
pub export fn b() void { | ||
_ = &extern_var; | ||
} | ||
|
||
pub export fn c() align(0) void {} | ||
|
||
pub export fn d() void { | ||
_ = *align(0) fn () i32; | ||
} | ||
|
||
pub export fn e() void { | ||
var local_var: i32 align(0) = undefined; | ||
_ = &local_var; | ||
} | ||
|
||
pub export fn f() void { | ||
_ = *align(0) i32; | ||
} | ||
|
||
pub export fn g() void { | ||
_ = []align(0) i32; | ||
} | ||
|
||
pub export fn h() void { | ||
_ = struct { field: i32 align(0) }; | ||
} | ||
|
||
pub export fn i() void { | ||
_ = union { field: i32 align(0) }; | ||
} | ||
|
||
// error | ||
// backend=stage2 | ||
// target=native | ||
// | ||
// :1:31: error: alignment must be >= 1 | ||
// :7:38: error: alignment must be >= 1 | ||
// :13:25: error: alignment must be >= 1 | ||
// :16:16: error: alignment must be >= 1 | ||
// :20:30: error: alignment must be >= 1 | ||
// :25:16: error: alignment must be >= 1 | ||
// :29:17: error: alignment must be >= 1 | ||
// :33:35: error: alignment must be >= 1 | ||
// :37:34: error: alignment must be >= 1 |
2 changes: 1 addition & 1 deletion
2
test/cases/compile_errors/function_alignment_on_unsupported_target.zig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export fn entry() align(0) void {} | ||
export fn entry() align(64) void {} | ||
|
||
// error | ||
// backend=stage2 | ||
|