diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-02-10 00:14:30 -0500 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-02-10 00:14:30 -0500 |
| commit | b8cbe3872e702ab8ec388e75cb711330a45825b0 (patch) | |
| tree | 3f0162c85bee328083466f1c2d164eb4035450bb /src/analyze.cpp | |
| parent | caf672c49586f1af5e3d41ae200aded991b8b0f7 (diff) | |
| download | zig-b8cbe3872e702ab8ec388e75cb711330a45825b0.tar.gz zig-b8cbe3872e702ab8ec388e75cb711330a45825b0.zip | |
added C pointer type and implicit int-to-ptr for this type
See #1059
Diffstat (limited to 'src/analyze.cpp')
| -rw-r--r-- | src/analyze.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp index 970d1cc382..e561050e0d 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -417,6 +417,18 @@ ZigType *get_promise_type(CodeGen *g, ZigType *result_type) { return entry; } +static const char *ptr_len_to_star_str(PtrLen ptr_len) { + switch (ptr_len) { + case PtrLenSingle: + return "*"; + case PtrLenUnknown: + return "[*]"; + case PtrLenC: + return "[*c]"; + } + zig_unreachable(); +} + ZigType *get_pointer_to_type_extra(CodeGen *g, ZigType *child_type, bool is_const, bool is_volatile, PtrLen ptr_len, uint32_t byte_alignment, uint32_t bit_offset_in_host, uint32_t host_int_bytes) @@ -466,7 +478,7 @@ ZigType *get_pointer_to_type_extra(CodeGen *g, ZigType *child_type, bool is_cons ZigType *entry = new_type_table_entry(ZigTypeIdPointer); - const char *star_str = ptr_len == PtrLenSingle ? "*" : "[*]"; + const char *star_str = ptr_len_to_star_str(ptr_len); const char *const_str = is_const ? "const " : ""; const char *volatile_str = is_volatile ? "volatile " : ""; buf_resize(&entry->name, 0); |
