Commit 3e80aa9079
Changed files (2)
src
test
cases
compile_errors
src/Sema.zig
@@ -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) {
test/cases/compile_errors/alignOf_bad_type.zig
@@ -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'