mirror of
https://github.com/ziglang/zig.git
synced 2026-01-04 12:33:19 +00:00
Sema: validate @alignOf type
This commit is contained in:
parent
540130650f
commit
3e80aa9079
@ -16492,6 +16492,9 @@ fn zirAlignOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
|
||||
const inst_data = sema.code.instructions.items(.data)[inst].un_node;
|
||||
const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
|
||||
const ty = try sema.resolveType(block, operand_src, inst_data.operand);
|
||||
if (ty.isNoReturn()) {
|
||||
return sema.fail(block, operand_src, "no align available for type '{}'", .{ty.fmt(sema.mod)});
|
||||
}
|
||||
const target = sema.mod.getTarget();
|
||||
const val = try ty.lazyAbiAlignment(target, sema.arena);
|
||||
if (val.tag() == .lazy_align) {
|
||||
|
||||
9
test/cases/compile_errors/alignOf_bad_type.zig
Normal file
9
test/cases/compile_errors/alignOf_bad_type.zig
Normal file
@ -0,0 +1,9 @@
|
||||
export fn entry() usize {
|
||||
return @alignOf(noreturn);
|
||||
}
|
||||
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :2:21: error: no align available for type 'noreturn'
|
||||
Loading…
x
Reference in New Issue
Block a user