fix type_is_codegen_pointer being used incorrectly

The names of these functions should probably change, but at least
the semantics are correct now:
 * type_is_codegen_pointer - the type is either a fn, ptr, or promise
 * get_codegen_ptr_type -
   - ?&T and &T returns &T
   - ?promise and promise returns promise
   - ?fn()void and fn()void returns fn()void
   - otherwise returns nullptr
This commit is contained in:
Andrew Kelley
2018-02-23 12:49:21 -05:00
parent 99985ad6fc
commit 40dbcd09da
3 changed files with 13 additions and 13 deletions

View File

@@ -3679,7 +3679,7 @@ TypeTableEntry *get_codegen_ptr_type(TypeTableEntry *type) {
}
bool type_is_codegen_pointer(TypeTableEntry *type) {
return get_codegen_ptr_type(type) != nullptr;
return get_codegen_ptr_type(type) == type;
}
uint32_t get_ptr_align(TypeTableEntry *type) {
@@ -3688,6 +3688,8 @@ uint32_t get_ptr_align(TypeTableEntry *type) {
return ptr_type->data.pointer.alignment;
} else if (ptr_type->id == TypeTableEntryIdFn) {
return (ptr_type->data.fn.fn_type_id.alignment == 0) ? 1 : ptr_type->data.fn.fn_type_id.alignment;
} else if (ptr_type->id == TypeTableEntryIdPromise) {
return 1;
} else {
zig_unreachable();
}
@@ -3723,7 +3725,7 @@ static void define_local_param_variables(CodeGen *g, FnTableEntry *fn_table_entr
TypeTableEntry *param_type = param_info->type;
bool is_noalias = param_info->is_noalias;
if (is_noalias && !type_is_codegen_pointer(param_type)) {
if (is_noalias && get_codegen_ptr_type(param_type) == nullptr) {
add_node_error(g, param_decl_node, buf_sprintf("noalias on non-pointer parameter"));
}