aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-03-06 16:37:03 -0500
committerAndrew Kelley <superjoe30@gmail.com>2018-03-06 16:37:03 -0500
commit07e47c058c480914d45ec0b1f9c61b76f59e6299 (patch)
treeebbe6e0a1e2982de491708e3f538cad12a0eddda /src/ir.cpp
parent46e258c9f76cee5b37042913c34b3a1a07cce0a6 (diff)
downloadzig-07e47c058c480914d45ec0b1f9c61b76f59e6299.tar.gz
zig-07e47c058c480914d45ec0b1f9c61b76f59e6299.zip
ptrCast builtin now gives an error for removing const qualifier
closes #384
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index 3d1926298d..251c55df4f 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -16816,6 +16816,11 @@ static TypeTableEntry *ir_analyze_instruction_ptr_cast(IrAnalyze *ira, IrInstruc
return ira->codegen->builtin_types.entry_invalid;
}
+ if (get_ptr_const(src_type) && !get_ptr_const(dest_type)) {
+ ir_add_error(ira, &instruction->base, buf_sprintf("cast discards const qualifier"));
+ return ira->codegen->builtin_types.entry_invalid;
+ }
+
if (instr_is_comptime(ptr)) {
ConstExprValue *val = ir_resolve_const(ira, ptr, UndefOk);
if (!val)