diff options
| author | LemonBoy <thatlemon@gmail.com> | 2020-02-23 09:44:19 +0100 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-03-09 14:05:38 -0400 |
| commit | 14bbb828326a8b08cf6680a44d992e64a5de34f5 (patch) | |
| tree | 41f2a9285ed5324d7f45f86e3657d93346899fa6 /src/ir.cpp | |
| parent | 648f94c0275a85fece347ced013f89ee5eb5d800 (diff) | |
| download | zig-14bbb828326a8b08cf6680a44d992e64a5de34f5.tar.gz zig-14bbb828326a8b08cf6680a44d992e64a5de34f5.zip | |
ir: Fix lazy comparison between @alignOf and zero
Closes #4527
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index 110778fb9a..3adf6d1e0c 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -15565,9 +15565,20 @@ static Error lazy_cmp_zero(CodeGen *codegen, AstNode *source_node, ZigValue *val switch (val->data.x_lazy->id) { case LazyValueIdInvalid: zig_unreachable(); - case LazyValueIdAlignOf: - *result = CmpGT; + case LazyValueIdAlignOf: { + LazyValueAlignOf *lazy_align_of = reinterpret_cast<LazyValueAlignOf *>(val->data.x_lazy); + IrAnalyze *ira = lazy_align_of->ira; + + uint32_t abi_align; + if ((err = type_val_resolve_abi_align(ira->codegen, source_node, lazy_align_of->target_type->value, + &abi_align))) + { + return err; + } + + *result = (abi_align == 0) ? CmpEQ : CmpGT; return ErrorNone; + } case LazyValueIdSizeOf: { LazyValueSizeOf *lazy_size_of = reinterpret_cast<LazyValueSizeOf *>(val->data.x_lazy); IrAnalyze *ira = lazy_size_of->ira; |
