aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-07-09 17:14:42 -0400
committerAndrew Kelley <superjoe30@gmail.com>2018-07-09 17:14:42 -0400
commit3f4d0ecd7e5a57b425b1cd99139145e7e509c3c6 (patch)
tree76d1d16a397e44c04167456116d6d3cc91f0b994 /src/ir.cpp
parent9462852433a815496e0edf5d5b2e00726f5ea072 (diff)
parent0ac1b83885c7f2a97a8ac25657afcb5c9b80afb4 (diff)
downloadzig-3f4d0ecd7e5a57b425b1cd99139145e7e509c3c6.tar.gz
zig-3f4d0ecd7e5a57b425b1cd99139145e7e509c3c6.zip
Merge remote-tracking branch 'origin/master' into m-n-threading
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index 3fc8306339..2dc6ddad2c 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%" ZIG_PRI_x64 " 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;
@@ -19796,6 +19805,12 @@ static TypeTableEntry *ir_analyze_instruction_ptr_to_int(IrAnalyze *ira, IrInstr
return ira->codegen->builtin_types.entry_invalid;
}
+ if (!type_has_bits(target->value.type)) {
+ ir_add_error(ira, target,
+ buf_sprintf("pointer to size 0 type has no address"));
+ return ira->codegen->builtin_types.entry_invalid;
+ }
+
if (instr_is_comptime(target)) {
ConstExprValue *val = ir_resolve_const(ira, target, UndefBad);
if (!val)