aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-03-08 17:02:18 -0500
committerAndrew Kelley <superjoe30@gmail.com>2017-03-08 17:02:18 -0500
commit558ae2f21a49ae5d75d1836cf86dbe4250d5fdbe (patch)
treefbb83e35a1070db0fc70dabfcaf144473d5747b9 /src/ir.cpp
parentddd9624e2d03b71754e1591637f0f4f835c01a35 (diff)
downloadzig-558ae2f21a49ae5d75d1836cf86dbe4250d5fdbe.tar.gz
zig-558ae2f21a49ae5d75d1836cf86dbe4250d5fdbe.zip
fix a case of invalid ptr const-ness
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index 2a8d6fe418..4a5f937a47 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -4349,7 +4349,7 @@ static IrInstruction *ir_lval_wrap(IrBuilder *irb, Scope *scope, IrInstruction *
// We needed a pointer to a value, but we got a value. So we create
// an instruction which just makes a const pointer of it.
- return ir_build_ref(irb, scope, value->source_node, value, true, false);
+ return ir_build_ref(irb, scope, value->source_node, value, lval.is_const, lval.is_volatile);
}
static IrInstruction *ir_gen_address_of(IrBuilder *irb, Scope *scope, AstNode *node,
@@ -9420,7 +9420,10 @@ static TypeTableEntry *ir_analyze_instruction_store_ptr(IrAnalyze *ira, IrInstru
return ira->codegen->builtin_types.entry_invalid;
if (instr_is_comptime(ptr) && ptr->value.data.x_ptr.special != ConstPtrSpecialHardCodedAddr) {
- assert(ptr->value.data.x_ptr.mut != ConstPtrMutComptimeConst);
+ if (ptr->value.data.x_ptr.mut == ConstPtrMutComptimeConst) {
+ ir_add_error(ira, &store_ptr_instruction->base, buf_sprintf("cannot assign to constant"));
+ return ira->codegen->builtin_types.entry_invalid;
+ }
if (ptr->value.data.x_ptr.mut == ConstPtrMutComptimeVar) {
if (instr_is_comptime(casted_value)) {
ConstExprValue *dest_val = const_ptr_pointee(&ptr->value);