| ... | @@ -20431,9 +20431,11 @@ fn zirReify( | ... | @@ -20431,9 +20431,11 @@ fn zirReify( |
| 20431 | return sema.fail(block, src, "alignment must fit in 'u32'", .{}); | 20431 | return sema.fail(block, src, "alignment must fit in 'u32'", .{}); |
| 20432 | } | 20432 | } |
| 20433 | | 20433 | |
| 20434 | const abi_align = Alignment.fromByteUnits( | 20434 | const alignment_val_int = (try alignment_val.getUnsignedIntAdvanced(mod, sema)).?; |
| 20435 | (try alignment_val.getUnsignedIntAdvanced(mod, sema)).?, | 20435 | if (alignment_val_int > 0 and !math.isPowerOfTwo(alignment_val_int)) { |
| 20436 | ); | 20436 | return sema.fail(block, src, "alignment value '{d}' is not a power of two or zero", .{alignment_val_int}); |
| | 20437 | } |
| | 20438 | const abi_align = Alignment.fromByteUnits(alignment_val_int); |
| 20437 | | 20439 | |
| 20438 | const elem_ty = child_val.toType(); | 20440 | const elem_ty = child_val.toType(); |
| 20439 | if (abi_align != .none) { | 20441 | if (abi_align != .none) { |
| ... | @@ -20895,7 +20897,14 @@ fn zirReify( | ... | @@ -20895,7 +20897,14 @@ fn zirReify( |
| 20895 | } | 20897 | } |
| 20896 | | 20898 | |
| 20897 | const field_ty = type_val.toType(); | 20899 | const field_ty = type_val.toType(); |
| 20898 | const field_align = Alignment.fromByteUnits((try alignment_val.getUnsignedIntAdvanced(mod, sema)).?); | 20900 | const alignment_val_int = (try alignment_val.getUnsignedIntAdvanced(mod, sema)).?; |
| | 20901 | if (alignment_val_int > 0 and !math.isPowerOfTwo(alignment_val_int)) { |
| | 20902 | // TODO: better source location |
| | 20903 | return sema.fail(block, src, "alignment value '{d}' is not a power of two or zero", .{ |
| | 20904 | alignment_val_int, |
| | 20905 | }); |
| | 20906 | } |
| | 20907 | const field_align = Alignment.fromByteUnits(alignment_val_int); |
| 20899 | any_aligned_fields = any_aligned_fields or field_align != .none; | 20908 | any_aligned_fields = any_aligned_fields or field_align != .none; |
| 20900 | | 20909 | |
| 20901 | try union_fields.append(sema.arena, .{ | 20910 | try union_fields.append(sema.arena, .{ |
| ... | @@ -21214,6 +21223,7 @@ fn reifyStruct( | ... | @@ -21214,6 +21223,7 @@ fn reifyStruct( |
| 21214 | if (abi_align != 0) return sema.fail(block, src, "alignment in a packed struct field must be set to 0", .{}); | 21223 | if (abi_align != 0) return sema.fail(block, src, "alignment in a packed struct field must be set to 0", .{}); |
| 21215 | if (is_comptime_val.toBool()) return sema.fail(block, src, "packed struct fields cannot be marked comptime", .{}); | 21224 | if (is_comptime_val.toBool()) return sema.fail(block, src, "packed struct fields cannot be marked comptime", .{}); |
| 21216 | } else { | 21225 | } else { |
| | 21226 | if (abi_align > 0 and !math.isPowerOfTwo(abi_align)) return sema.fail(block, src, "alignment value '{d}' is not a power of two or zero", .{abi_align}); |
| 21217 | struct_type.field_aligns.get(ip)[i] = Alignment.fromByteUnits(abi_align); | 21227 | struct_type.field_aligns.get(ip)[i] = Alignment.fromByteUnits(abi_align); |
| 21218 | } | 21228 | } |
| 21219 | if (layout == .Extern and is_comptime_val.toBool()) { | 21229 | if (layout == .Extern and is_comptime_val.toBool()) { |