diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-07-09 11:13:29 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-07-09 11:13:29 -0400 |
| commit | 2ee67b7642cfeef36d8ebbc08080202b5b1d1958 (patch) | |
| tree | d031afb8e49237cf040b8fe4c2af72ab86239abd /src/ir.cpp | |
| parent | 9eb51e20ed1a040a617541303db760f80ffd3aa1 (diff) | |
| download | zig-2ee67b7642cfeef36d8ebbc08080202b5b1d1958.tar.gz zig-2ee67b7642cfeef36d8ebbc08080202b5b1d1958.zip | |
langref: docs for invalid error set cast and incorrect pointer alignment
also add detection of incorrect pointer alignment at compile-time
of pointers that were constructed with `@intToPtr`.
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index 5e4c847e14..dcd39ccfe5 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -19370,6 +19370,15 @@ static IrInstruction *ir_align_cast(IrAnalyze *ira, IrInstruction *target, uint3 if (!val) return ira->codegen->invalid_instruction; + if (val->data.x_ptr.special == ConstPtrSpecialHardCodedAddr && + val->data.x_ptr.data.hard_coded_addr.addr % align_bytes != 0) + { + ir_add_error(ira, target, + buf_sprintf("pointer address 0x%lx is not aligned to %" PRIu32 " bytes", + val->data.x_ptr.data.hard_coded_addr.addr, align_bytes)); + return ira->codegen->invalid_instruction; + } + IrInstruction *result = ir_create_const(&ira->new_irb, target->scope, target->source_node, result_type); copy_const_val(&result->value, val, false); result->value.type = result_type; |
