diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2017-02-24 15:00:47 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2017-02-24 15:01:19 -0500 |
| commit | a665872e881920e8020a513340d2427b88a55bd6 (patch) | |
| tree | ff81a6b509584d737d0df15d293dc01ae1390469 /src/analyze.cpp | |
| parent | 3b40aaa01fb15799cf27d662229597ac98e2ab77 (diff) | |
| download | zig-a665872e881920e8020a513340d2427b88a55bd6.tar.gz zig-a665872e881920e8020a513340d2427b88a55bd6.zip | |
add compile error for ignoring return value
also introduce the _ identifier which you can assign to
to discard a return value
closes #219
Diffstat (limited to 'src/analyze.cpp')
| -rw-r--r-- | src/analyze.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp index 6b864a7947..842ddbdf48 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -3091,6 +3091,9 @@ static uint32_t hash_const_val(ConstExprValue *const_val) { hash_val += 4048518294; hash_val += hash_size(const_val->data.x_ptr.data.hard_coded_addr.addr); return hash_val; + case ConstPtrSpecialDiscard: + hash_val += 2010123162; + return hash_val; } zig_unreachable(); } @@ -3601,6 +3604,8 @@ bool const_values_equal(ConstExprValue *a, ConstExprValue *b) { if (a->data.x_ptr.data.hard_coded_addr.addr != b->data.x_ptr.data.hard_coded_addr.addr) return false; return true; + case ConstPtrSpecialDiscard: + return true; } zig_unreachable(); case TypeTableEntryIdArray: @@ -3785,6 +3790,9 @@ void render_const_value(Buf *buf, ConstExprValue *const_val) { buf_appendf(buf, "(&%s)(%" PRIx64 ")", buf_ptr(&canon_type->data.pointer.child_type->name), const_val->data.x_ptr.data.hard_coded_addr.addr); return; + case ConstPtrSpecialDiscard: + buf_append_str(buf, "&_"); + return; } zig_unreachable(); case TypeTableEntryIdFn: |
