zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit aee973829d7b101d76e94d9aee15b1bef33094c0 (tree)
parent c968d8756c9158433a9fb30db1f4989d1148cc7f
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Sun, 20 Jan 2019 14:09:46 -0500

Merge branch 'kristate-zig-backport-issue1883'

Diffstat:
Msrc/analyze.cpp | 7+++++++
Mtest/compile_errors.zig | 9+++++++++
2 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/src/analyze.cpp b/src/analyze.cpp @@ -5751,6 +5751,13 @@ void eval_min_max_value(CodeGen *g, ZigType *type_entry, ConstExprValue *const_v } void render_const_val_ptr(CodeGen *g, Buf *buf, ConstExprValue *const_val, ZigType *type_entry) { + assert(type_entry->id == ZigTypeIdPointer); + + if (type_entry->data.pointer.child_type->id == ZigTypeIdOpaque) { + buf_append_buf(buf, &type_entry->name); + return; + } + switch (const_val->data.x_ptr.special) { case ConstPtrSpecialInvalid: zig_unreachable(); diff --git a/test/compile_errors.zig b/test/compile_errors.zig @@ -2,6 +2,15 @@ const tests = @import("tests.zig"); pub fn addCases(cases: *tests.CompileErrorContext) void { cases.add( + "compile log a pointer to an opaque value", + \\export fn entry() void { + \\ @compileLog(@ptrCast(*const c_void, &entry)); + \\} + , + ".tmp_source.zig:2:5: error: found compile log statement", + ); + + cases.add( "duplicate boolean switch value", \\comptime { \\ const x = switch (true) {