AstGen: disallow alignment on function types
A pointer type already has an alignment, so this information does not need to be duplicated on the function type. This already has precedence with addrspace which is already disallowed on function types for this reason. Also fixes `@TypeOf(&func)` to have the correct addrspace and alignment.
This commit is contained in:
@@ -1,28 +1,16 @@
|
||||
comptime {
|
||||
var a: *align(2) @TypeOf(foo) = undefined;
|
||||
_ = &a;
|
||||
}
|
||||
fn foo() void {}
|
||||
fn align1() align(1) void {}
|
||||
fn align2() align(2) void {}
|
||||
|
||||
comptime {
|
||||
var a: *align(1) fn () void = undefined;
|
||||
_ = &a;
|
||||
}
|
||||
comptime {
|
||||
var a: *align(2) fn () align(2) void = undefined;
|
||||
_ = &a;
|
||||
}
|
||||
comptime {
|
||||
var a: *align(2) fn () void = undefined;
|
||||
_ = &a;
|
||||
}
|
||||
comptime {
|
||||
var a: *align(1) fn () align(2) void = undefined;
|
||||
_ = &a;
|
||||
_ = @as(*align(1) const fn () void, &align2);
|
||||
_ = @as(*align(1) const fn () void, &align1);
|
||||
_ = @as(*align(2) const fn () void, &align2);
|
||||
_ = @as(*align(2) const fn () void, &align1);
|
||||
}
|
||||
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :20:19: error: function pointer alignment disagrees with function alignment
|
||||
// :8:41: error: expected type '*align(2) const fn () void', found '*const fn () void'
|
||||
// :8:41: note: pointer alignment '1' cannot cast into pointer alignment '2'
|
||||
|
||||
Reference in New Issue
Block a user