aboutsummaryrefslogtreecommitdiff
path: root/src/analyze.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/analyze.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/analyze.cpp')
-rw-r--r--src/analyze.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp
index 1e16a8dbd1..fb7f04d6d2 100644
--- a/src/analyze.cpp
+++ b/src/analyze.cpp
@@ -3753,6 +3753,19 @@ uint32_t get_ptr_align(TypeTableEntry *type) {
}
}
+bool get_ptr_const(TypeTableEntry *type) {
+ TypeTableEntry *ptr_type = get_codegen_ptr_type(type);
+ if (ptr_type->id == TypeTableEntryIdPointer) {
+ return ptr_type->data.pointer.is_const;
+ } else if (ptr_type->id == TypeTableEntryIdFn) {
+ return true;
+ } else if (ptr_type->id == TypeTableEntryIdPromise) {
+ return true;
+ } else {
+ zig_unreachable();
+ }
+}
+
AstNode *get_param_decl_node(FnTableEntry *fn_entry, size_t index) {
if (fn_entry->param_source_nodes)
return fn_entry->param_source_nodes[index];