From 094336f07cdf42f2f79df5b190ccc0139412cfbc Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 5 May 2016 17:19:01 -0700 Subject: add integer wrapping see #46 --- src/analyze.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/analyze.cpp') diff --git a/src/analyze.cpp b/src/analyze.cpp index 556c905e43..7f02cc9aff 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -206,7 +206,7 @@ static bool type_is_complete(TypeTableEntry *type_entry) { } TypeTableEntry *get_smallest_unsigned_int_type(CodeGen *g, uint64_t x) { - return get_int_type(g, false, bits_needed_for_unsigned(x)); + return get_int_type(g, false, false, bits_needed_for_unsigned(x)); } static TypeTableEntry *get_generic_fn_type(CodeGen *g, AstNode *decl_node) { @@ -6453,7 +6453,7 @@ bool is_node_void_expr(AstNode *node) { return false; } -TypeTableEntry **get_int_type_ptr(CodeGen *g, bool is_signed, int size_in_bits) { +TypeTableEntry **get_int_type_ptr(CodeGen *g, bool is_signed, bool is_wrapping, int size_in_bits) { int index; if (size_in_bits == 8) { index = 0; @@ -6466,11 +6466,11 @@ TypeTableEntry **get_int_type_ptr(CodeGen *g, bool is_signed, int size_in_bits) } else { zig_unreachable(); } - return &g->builtin_types.entry_int[is_signed ? 0 : 1][index]; + return &g->builtin_types.entry_int[is_signed ? 0 : 1][is_wrapping ? 0 : 1][index]; } -TypeTableEntry *get_int_type(CodeGen *g, bool is_signed, int size_in_bits) { - return *get_int_type_ptr(g, is_signed, size_in_bits); +TypeTableEntry *get_int_type(CodeGen *g, bool is_signed, bool is_wrapping, int size_in_bits) { + return *get_int_type_ptr(g, is_signed, is_wrapping, size_in_bits); } TypeTableEntry **get_c_int_type_ptr(CodeGen *g, CIntType c_int_type) { -- cgit v1.2.3