From 558ae2f21a49ae5d75d1836cf86dbe4250d5fdbe Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 8 Mar 2017 17:02:18 -0500 Subject: fix a case of invalid ptr const-ness --- src/ir.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/ir.cpp') 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); -- cgit v1.2.3