authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-04-10 20:02:39-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-04-10 20:02:39-04:00
log11a655032400fda22132c54131546f3e671476a9
tree929648da483a3ec3693299e9f6aa8108a120ca09
parent34eff503265834172f89a8635e49e9f4d124db51

fix some -Wconversion errors


16 files changed, 206 insertions(+), 193 deletions(-)

src/all_types.hpp+4-4
......@@ -277,7 +277,7 @@ struct TldVar {
277277
278278 VariableTableEntry *var;
279279 AstNode *set_global_align_node;
280 uint64_t alignment;
280 uint32_t alignment;
281281 AstNode *set_global_section_node;
282282 Buf *section_name;
283283 AstNode *set_global_linkage_node;
......@@ -888,7 +888,7 @@ struct TypeTableEntryPointer {
888888};
889889
890890struct TypeTableEntryInt {
891 size_t bit_count;
891 uint32_t bit_count;
892892 bool is_signed;
893893};
894894
......@@ -1146,7 +1146,7 @@ struct FnTableEntry {
11461146 ZigList<VariableTableEntry *> variable_list;
11471147
11481148 AstNode *set_global_align_node;
1149 uint64_t alignment;
1149 uint32_t alignment;
11501150 AstNode *set_global_section_node;
11511151 Buf *section_name;
11521152 AstNode *set_global_linkage_node;
......@@ -1251,7 +1251,7 @@ struct TypeId {
12511251 } array;
12521252 struct {
12531253 bool is_signed;
1254 uint8_t bit_count;
1254 uint32_t bit_count;
12551255 } integer;
12561256 } data;
12571257};
src/analyze.cpp+69-65
......@@ -163,7 +163,7 @@ static TypeTableEntry *new_container_type_entry(TypeTableEntryId id, AstNode *so
163163
164164
165165// TODO no reason to limit to 8/16/32/64
166static size_t bits_needed_for_unsigned(uint64_t x) {
166static uint8_t bits_needed_for_unsigned(uint64_t x) {
167167 if (x <= UINT8_MAX) {
168168 return 8;
169169 } else if (x <= UINT16_MAX) {
......@@ -578,13 +578,14 @@ TypeTableEntry *get_array_type(CodeGen *g, TypeTableEntry *child_type, uint64_t
578578 buf_appendf(&entry->name, "[%" PRIu64 "]%s", array_size, buf_ptr(&child_type->name));
579579
580580 if (!entry->zero_bits) {
581 entry->type_ref = child_type->type_ref ? LLVMArrayType(child_type->type_ref, array_size) : nullptr;
581 entry->type_ref = child_type->type_ref ? LLVMArrayType(child_type->type_ref,
582 (unsigned int)array_size) : nullptr;
582583
583584 uint64_t debug_size_in_bits = 8*LLVMStoreSizeOfType(g->target_data_ref, entry->type_ref);
584585 uint64_t debug_align_in_bits = 8*LLVMABISizeOfType(g->target_data_ref, entry->type_ref);
585586
586587 entry->di_type = ZigLLVMCreateDebugArrayType(g->dbuilder, debug_size_in_bits,
587 debug_align_in_bits, child_type->di_type, array_size);
588 debug_align_in_bits, child_type->di_type, (int)array_size);
588589 }
589590 entry->data.array.child_type = child_type;
590591 entry->data.array.len = array_size;
......@@ -911,9 +912,9 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
911912 fn_type->data.fn.gen_param_count = gen_param_index;
912913
913914 fn_type->data.fn.raw_type_ref = LLVMFunctionType(gen_return_type->type_ref,
914 gen_param_types, gen_param_index, fn_type_id->is_var_args);
915 gen_param_types, (unsigned int)gen_param_index, fn_type_id->is_var_args);
915916 fn_type->type_ref = LLVMPointerType(fn_type->data.fn.raw_type_ref, 0);
916 fn_type->di_type = ZigLLVMCreateSubroutineType(g->dbuilder, param_di_types, gen_param_index + 1, 0);
917 fn_type->di_type = ZigLLVMCreateSubroutineType(g->dbuilder, param_di_types, (int)(gen_param_index + 1), 0);
917918 }
918919
919920 g->fn_type_table.put(&fn_type->data.fn.fn_type_id, fn_type);
......@@ -954,13 +955,13 @@ TypeTableEntry *get_partial_container_type(CodeGen *g, Scope *scope, ContainerKi
954955 break;
955956 }
956957
957 unsigned line = decl_node ? decl_node->line : 0;
958 size_t line = decl_node ? decl_node->line : 0;
958959
959960 ImportTableEntry *import = get_scope_import(scope);
960961 entry->type_ref = LLVMStructCreateNamed(LLVMGetGlobalContext(), name);
961962 entry->di_type = ZigLLVMCreateReplaceableCompositeType(g->dbuilder,
962963 ZigLLVMTag_DW_structure_type(), name,
963 ZigLLVMFileToScope(import->di_file), import->di_file, line + 1);
964 ZigLLVMFileToScope(import->di_file), import->di_file, (unsigned)(line + 1));
964965
965966 buf_init_from_str(&entry->name, name);
966967
......@@ -1264,7 +1265,7 @@ static void resolve_enum_type(CodeGen *g, TypeTableEntry *enum_type) {
12641265
12651266 union_inner_di_types[type_enum_field->gen_index] = ZigLLVMCreateDebugMemberType(g->dbuilder,
12661267 ZigLLVMTypeToScope(enum_type->di_type), buf_ptr(type_enum_field->name),
1267 import->di_file, field_node->line + 1,
1268 import->di_file, (unsigned)(field_node->line + 1),
12681269 debug_size_in_bits,
12691270 debug_align_in_bits,
12701271 0,
......@@ -1307,13 +1308,15 @@ static void resolve_enum_type(CodeGen *g, TypeTableEntry *enum_type) {
13071308 uint64_t tag_debug_size_in_bits = 8*LLVMStoreSizeOfType(g->target_data_ref, tag_type_entry->type_ref);
13081309 uint64_t tag_debug_align_in_bits = 8*LLVMABISizeOfType(g->target_data_ref, tag_type_entry->type_ref);
13091310 ZigLLVMDIType *tag_di_type = ZigLLVMCreateDebugEnumerationType(g->dbuilder,
1310 ZigLLVMTypeToScope(enum_type->di_type), "AnonEnum", import->di_file, decl_node->line + 1,
1311 ZigLLVMTypeToScope(enum_type->di_type), "AnonEnum",
1312 import->di_file, (unsigned)(decl_node->line + 1),
13111313 tag_debug_size_in_bits, tag_debug_align_in_bits, di_enumerators, field_count,
13121314 tag_type_entry->di_type, "");
13131315
13141316 // create debug type for union
13151317 ZigLLVMDIType *union_di_type = ZigLLVMCreateDebugUnionType(g->dbuilder,
1316 ZigLLVMTypeToScope(enum_type->di_type), "AnonUnion", import->di_file, decl_node->line + 1,
1318 ZigLLVMTypeToScope(enum_type->di_type), "AnonUnion",
1319 import->di_file, (unsigned)(decl_node->line + 1),
13171320 biggest_union_member_size_in_bits, biggest_align_in_bits, 0, union_inner_di_types,
13181321 gen_field_count, 0, "");
13191322
......@@ -1321,7 +1324,7 @@ static void resolve_enum_type(CodeGen *g, TypeTableEntry *enum_type) {
13211324 uint64_t tag_offset_in_bits = 8*LLVMOffsetOfElement(g->target_data_ref, enum_type->type_ref, 0);
13221325 ZigLLVMDIType *tag_member_di_type = ZigLLVMCreateDebugMemberType(g->dbuilder,
13231326 ZigLLVMTypeToScope(enum_type->di_type), "tag_field",
1324 import->di_file, decl_node->line + 1,
1327 import->di_file, (unsigned)(decl_node->line + 1),
13251328 tag_debug_size_in_bits,
13261329 tag_debug_align_in_bits,
13271330 tag_offset_in_bits,
......@@ -1330,7 +1333,7 @@ static void resolve_enum_type(CodeGen *g, TypeTableEntry *enum_type) {
13301333 uint64_t union_offset_in_bits = 8*LLVMOffsetOfElement(g->target_data_ref, enum_type->type_ref, 1);
13311334 ZigLLVMDIType *union_member_di_type = ZigLLVMCreateDebugMemberType(g->dbuilder,
13321335 ZigLLVMTypeToScope(enum_type->di_type), "union_field",
1333 import->di_file, decl_node->line + 1,
1336 import->di_file, (unsigned)(decl_node->line + 1),
13341337 biggest_union_member_size_in_bits,
13351338 biggest_align_in_bits,
13361339 union_offset_in_bits,
......@@ -1348,7 +1351,7 @@ static void resolve_enum_type(CodeGen *g, TypeTableEntry *enum_type) {
13481351 ZigLLVMDIType *replacement_di_type = ZigLLVMCreateDebugStructType(g->dbuilder,
13491352 ZigLLVMFileToScope(import->di_file),
13501353 buf_ptr(&enum_type->name),
1351 import->di_file, decl_node->line + 1,
1354 import->di_file, (unsigned)(decl_node->line + 1),
13521355 debug_size_in_bits,
13531356 debug_align_in_bits,
13541357 0, nullptr, di_root_members, 2, 0, nullptr, "");
......@@ -1364,7 +1367,7 @@ static void resolve_enum_type(CodeGen *g, TypeTableEntry *enum_type) {
13641367 uint64_t tag_debug_align_in_bits = 8*LLVMABISizeOfType(g->target_data_ref, tag_type_entry->type_ref);
13651368 ZigLLVMDIType *tag_di_type = ZigLLVMCreateDebugEnumerationType(g->dbuilder,
13661369 ZigLLVMFileToScope(import->di_file), buf_ptr(&enum_type->name),
1367 import->di_file, decl_node->line + 1,
1370 import->di_file, (unsigned)(decl_node->line + 1),
13681371 tag_debug_size_in_bits,
13691372 tag_debug_align_in_bits,
13701373 di_enumerators, field_count,
......@@ -1499,7 +1502,7 @@ static void resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) {
14991502 type_struct_field->unaligned_bit_count = field_size_in_bits;
15001503
15011504 size_t full_bit_count = next_packed_bits_offset - first_packed_bits_offset_misalign;
1502 LLVMTypeRef int_type_ref = LLVMIntType(full_bit_count);
1505 LLVMTypeRef int_type_ref = LLVMIntType((unsigned)(full_bit_count));
15031506 if (8 * LLVMStoreSizeOfType(g->target_data_ref, int_type_ref) == full_bit_count) {
15041507 // next field recovers store alignment
15051508 element_types[gen_field_index] = int_type_ref;
......@@ -1529,9 +1532,9 @@ static void resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) {
15291532 }
15301533 if (first_packed_bits_offset_misalign != SIZE_MAX) {
15311534 size_t full_bit_count = packed_bits_offset - first_packed_bits_offset_misalign;
1532 LLVMTypeRef int_type_ref = LLVMIntType(full_bit_count);
1535 LLVMTypeRef int_type_ref = LLVMIntType((unsigned)full_bit_count);
15331536 size_t store_bit_count = 8 * LLVMStoreSizeOfType(g->target_data_ref, int_type_ref);
1534 element_types[gen_field_index] = LLVMIntType(store_bit_count);
1537 element_types[gen_field_index] = LLVMIntType((unsigned)store_bit_count);
15351538 gen_field_index += 1;
15361539 }
15371540
......@@ -1552,9 +1555,9 @@ static void resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) {
15521555
15531556 // the count may have been adjusting from packing bit fields
15541557 gen_field_count = gen_field_index;
1555 struct_type->data.structure.gen_field_count = gen_field_count;
1558 struct_type->data.structure.gen_field_count = (uint32_t)gen_field_count;
15561559
1557 LLVMStructSetBody(struct_type->type_ref, element_types, gen_field_count, packed);
1560 LLVMStructSetBody(struct_type->type_ref, element_types, (unsigned)gen_field_count, packed);
15581561 assert(LLVMStoreSizeOfType(g->target_data_ref, struct_type->type_ref) > 0);
15591562
15601563 ZigLLVMDIType **di_element_types = allocate<ZigLLVMDIType*>(debug_field_count);
......@@ -1593,15 +1596,16 @@ static void resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) {
15931596 debug_size_in_bits = type_struct_field->packed_bits_size;
15941597 debug_align_in_bits = 1;
15951598 debug_offset_in_bits = 8*LLVMOffsetOfElement(g->target_data_ref, struct_type->type_ref,
1596 gen_field_index) + type_struct_field->packed_bits_offset;
1599 (unsigned)gen_field_index) + type_struct_field->packed_bits_offset;
15971600 } else {
15981601 debug_size_in_bits = 8*LLVMStoreSizeOfType(g->target_data_ref, field_type->type_ref);
15991602 debug_align_in_bits = 8*LLVMABISizeOfType(g->target_data_ref, field_type->type_ref);
1600 debug_offset_in_bits = 8*LLVMOffsetOfElement(g->target_data_ref, struct_type->type_ref, gen_field_index);
1603 debug_offset_in_bits = 8*LLVMOffsetOfElement(g->target_data_ref, struct_type->type_ref,
1604 (unsigned)gen_field_index);
16011605 }
16021606 di_element_types[debug_field_index] = ZigLLVMCreateDebugMemberType(g->dbuilder,
16031607 ZigLLVMTypeToScope(struct_type->di_type), buf_ptr(type_struct_field->name),
1604 import->di_file, field_node->line + 1,
1608 import->di_file, (unsigned)(field_node->line + 1),
16051609 debug_size_in_bits,
16061610 debug_align_in_bits,
16071611 debug_offset_in_bits,
......@@ -1616,10 +1620,10 @@ static void resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) {
16161620 ZigLLVMDIType *replacement_di_type = ZigLLVMCreateDebugStructType(g->dbuilder,
16171621 ZigLLVMFileToScope(import->di_file),
16181622 buf_ptr(&struct_type->name),
1619 import->di_file, decl_node->line + 1,
1623 import->di_file, (unsigned)(decl_node->line + 1),
16201624 debug_size_in_bits,
16211625 debug_align_in_bits,
1622 0, nullptr, di_element_types, debug_field_count, 0, nullptr, "");
1626 0, nullptr, di_element_types, (int)debug_field_count, 0, nullptr, "");
16231627
16241628 ZigLLVMReplaceTemporary(g->dbuilder, struct_type->di_type, replacement_di_type);
16251629 struct_type->di_type = replacement_di_type;
......@@ -1647,7 +1651,7 @@ static void resolve_enum_zero_bits(CodeGen *g, TypeTableEntry *enum_type) {
16471651 assert(enum_type->di_type);
16481652
16491653 assert(!enum_type->data.enumeration.fields);
1650 uint32_t field_count = decl_node->data.container_decl.fields.length;
1654 uint32_t field_count = (uint32_t)decl_node->data.container_decl.fields.length;
16511655 enum_type->data.enumeration.src_field_count = field_count;
16521656 enum_type->data.enumeration.fields = allocate<TypeEnumField>(field_count);
16531657
......@@ -1700,7 +1704,7 @@ static void resolve_struct_zero_bits(CodeGen *g, TypeTableEntry *struct_type) {
17001704
17011705 assert(!struct_type->data.structure.fields);
17021706 size_t field_count = decl_node->data.container_decl.fields.length;
1703 struct_type->data.structure.src_field_count = field_count;
1707 struct_type->data.structure.src_field_count = (uint32_t)field_count;
17041708 struct_type->data.structure.fields = allocate<TypeStructField>(field_count);
17051709
17061710 Scope *scope = &struct_type->data.structure.decls_scope->base;
......@@ -1729,7 +1733,7 @@ static void resolve_struct_zero_bits(CodeGen *g, TypeTableEntry *struct_type) {
17291733 }
17301734
17311735 struct_type->data.structure.zero_bits_loop_flag = false;
1732 struct_type->data.structure.gen_field_count = gen_field_index;
1736 struct_type->data.structure.gen_field_count = (uint32_t)gen_field_index;
17331737 struct_type->zero_bits = (gen_field_index == 0);
17341738 struct_type->data.structure.zero_bits_known = true;
17351739}
......@@ -1985,7 +1989,7 @@ static void preview_error_value_decl(CodeGen *g, AstNode *node) {
19851989 } else {
19861990 size_t error_value_count = g->error_decls.length;
19871991 assert((uint32_t)error_value_count < (((uint32_t)1) << (uint32_t)g->err_tag_type->data.integral.bit_count));
1988 err->value = error_value_count;
1992 err->value = (uint32_t)error_value_count;
19891993 g->error_decls.append(node);
19901994 g->error_table.put(&err->name, err);
19911995 }
......@@ -2999,7 +3003,7 @@ bool is_node_void_expr(AstNode *node) {
29993003 return false;
30003004}
30013005
3002TypeTableEntry **get_int_type_ptr(CodeGen *g, bool is_signed, uint8_t size_in_bits) {
3006TypeTableEntry **get_int_type_ptr(CodeGen *g, bool is_signed, uint32_t size_in_bits) {
30033007 size_t index;
30043008 if (size_in_bits == 8) {
30053009 index = 0;
......@@ -3015,7 +3019,7 @@ TypeTableEntry **get_int_type_ptr(CodeGen *g, bool is_signed, uint8_t size_in_bi
30153019 return &g->builtin_types.entry_int[is_signed ? 0 : 1][index];
30163020}
30173021
3018TypeTableEntry *get_int_type(CodeGen *g, bool is_signed, uint8_t size_in_bits) {
3022TypeTableEntry *get_int_type(CodeGen *g, bool is_signed, uint32_t size_in_bits) {
30193023 TypeTableEntry **common_entry = get_int_type_ptr(g, is_signed, size_in_bits);
30203024 if (common_entry)
30213025 return *common_entry;
......@@ -3104,11 +3108,11 @@ void find_libc_lib_path(CodeGen *g) {
31043108}
31053109
31063110static uint32_t hash_ptr(void *ptr) {
3107 return ((uintptr_t)ptr) % UINT32_MAX;
3111 return (uint32_t)(((uintptr_t)ptr) % UINT32_MAX);
31083112}
31093113
31103114static uint32_t hash_size(size_t x) {
3111 return x % UINT32_MAX;
3115 return (uint32_t)(x % UINT32_MAX);
31123116}
31133117
31143118uint32_t fn_table_entry_hash(FnTableEntry* value) {
......@@ -3121,14 +3125,14 @@ bool fn_table_entry_eql(FnTableEntry *a, FnTableEntry *b) {
31213125
31223126uint32_t fn_type_id_hash(FnTypeId *id) {
31233127 uint32_t result = 0;
3124 result += id->is_extern ? 3349388391 : 0;
3125 result += id->is_naked ? 608688877 : 0;
3126 result += id->is_cold ? 3605523458 : 0;
3127 result += id->is_var_args ? 1931444534 : 0;
3128 result += id->is_extern ? (uint32_t)3349388391 : 0;
3129 result += id->is_naked ? (uint32_t)608688877 : 0;
3130 result += id->is_cold ? (uint32_t)3605523458 : 0;
3131 result += id->is_var_args ? (uint32_t)1931444534 : 0;
31283132 result += hash_ptr(id->return_type);
31293133 for (size_t i = 0; i < id->param_count; i += 1) {
31303134 FnTypeParamInfo *info = &id->param_info[i];
3131 result += info->is_noalias ? 892356923 : 0;
3135 result += info->is_noalias ? (uint32_t)892356923 : 0;
31323136 result += hash_ptr(info->type);
31333137 }
31343138 return result;
......@@ -3161,55 +3165,55 @@ static uint32_t hash_const_val(ConstExprValue *const_val) {
31613165 assert(const_val->special == ConstValSpecialStatic);
31623166 switch (const_val->type->id) {
31633167 case TypeTableEntryIdBool:
3164 return const_val->data.x_bool ? 127863866 : 215080464;
3168 return const_val->data.x_bool ? (uint32_t)127863866 : (uint32_t)215080464;
31653169 case TypeTableEntryIdMetaType:
31663170 return hash_ptr(const_val->data.x_type);
31673171 case TypeTableEntryIdVoid:
3168 return 4149439618;
3172 return (uint32_t)4149439618;
31693173 case TypeTableEntryIdInt:
31703174 case TypeTableEntryIdNumLitInt:
31713175 case TypeTableEntryIdEnumTag:
3172 return ((uint32_t)(bignum_to_twos_complement(&const_val->data.x_bignum) % UINT32_MAX)) * 1331471175;
3176 return ((uint32_t)(bignum_to_twos_complement(&const_val->data.x_bignum) % UINT32_MAX)) * (uint32_t)1331471175;
31733177 case TypeTableEntryIdFloat:
31743178 case TypeTableEntryIdNumLitFloat:
3175 return const_val->data.x_bignum.data.x_float * UINT32_MAX;
3179 return (uint32_t)(const_val->data.x_bignum.data.x_float * (uint32_t)UINT32_MAX);
31763180 case TypeTableEntryIdArgTuple:
3177 return const_val->data.x_arg_tuple.start_index * 281907309 +
3178 const_val->data.x_arg_tuple.end_index * 2290442768;
3181 return (uint32_t)const_val->data.x_arg_tuple.start_index * (uint32_t)281907309 +
3182 (uint32_t)const_val->data.x_arg_tuple.end_index * (uint32_t)2290442768;
31793183 case TypeTableEntryIdPointer:
31803184 {
31813185 uint32_t hash_val = 0;
31823186 switch (const_val->data.x_ptr.mut) {
31833187 case ConstPtrMutRuntimeVar:
3184 hash_val += 3500721036;
3188 hash_val += (uint32_t)3500721036;
31853189 break;
31863190 case ConstPtrMutComptimeConst:
3187 hash_val += 4214318515;
3191 hash_val += (uint32_t)4214318515;
31883192 break;
31893193 case ConstPtrMutComptimeVar:
3190 hash_val += 1103195694;
3194 hash_val += (uint32_t)1103195694;
31913195 break;
31923196 }
31933197 switch (const_val->data.x_ptr.special) {
31943198 case ConstPtrSpecialInvalid:
31953199 zig_unreachable();
31963200 case ConstPtrSpecialRef:
3197 hash_val += 2478261866;
3201 hash_val += (uint32_t)2478261866;
31983202 hash_val += hash_ptr(const_val->data.x_ptr.data.ref.pointee);
31993203 return hash_val;
32003204 case ConstPtrSpecialBaseArray:
3201 hash_val += 1764906839;
3205 hash_val += (uint32_t)1764906839;
32023206 hash_val += hash_ptr(const_val->data.x_ptr.data.base_array.array_val);
32033207 hash_val += hash_size(const_val->data.x_ptr.data.base_array.elem_index);
32043208 hash_val += const_val->data.x_ptr.data.base_array.is_cstr ? 1297263887 : 200363492;
32053209 return hash_val;
32063210 case ConstPtrSpecialBaseStruct:
3207 hash_val += 3518317043;
3211 hash_val += (uint32_t)3518317043;
32083212 hash_val += hash_ptr(const_val->data.x_ptr.data.base_struct.struct_val);
32093213 hash_val += hash_size(const_val->data.x_ptr.data.base_struct.field_index);
32103214 return hash_val;
32113215 case ConstPtrSpecialHardCodedAddr:
3212 hash_val += 4048518294;
3216 hash_val += (uint32_t)4048518294;
32133217 hash_val += hash_size(const_val->data.x_ptr.data.hard_coded_addr.addr);
32143218 return hash_val;
32153219 case ConstPtrSpecialDiscard:
......@@ -3954,7 +3958,7 @@ void render_const_value(Buf *buf, ConstExprValue *const_val) {
39543958 ConstExprValue *child_value = &const_val->data.x_array.elements[i];
39553959 uint64_t big_c = child_value->data.x_bignum.data.x_uint;
39563960 assert(big_c <= UINT8_MAX);
3957 uint8_t c = big_c;
3961 uint8_t c = (uint8_t)big_c;
39583962 if (c == '"') {
39593963 buf_append_str(buf, "\\\"");
39603964 } else {
......@@ -4051,14 +4055,14 @@ void render_const_value(Buf *buf, ConstExprValue *const_val) {
40514055 zig_unreachable();
40524056}
40534057
4054TypeTableEntry *make_int_type(CodeGen *g, bool is_signed, size_t size_in_bits) {
4058TypeTableEntry *make_int_type(CodeGen *g, bool is_signed, uint32_t size_in_bits) {
40554059 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdInt);
40564060 entry->is_copyable = true;
40574061 entry->type_ref = LLVMIntType(size_in_bits);
40584062
40594063 const char u_or_i = is_signed ? 'i' : 'u';
40604064 buf_resize(&entry->name, 0);
4061 buf_appendf(&entry->name, "%c%zu", u_or_i, size_in_bits);
4065 buf_appendf(&entry->name, "%c%" PRIu8, u_or_i, size_in_bits);
40624066
40634067 unsigned dwarf_tag;
40644068 if (is_signed) {
......@@ -4111,16 +4115,16 @@ uint32_t type_id_hash(TypeId x) {
41114115 zig_unreachable();
41124116 case TypeTableEntryIdPointer:
41134117 return hash_ptr(x.data.pointer.child_type) +
4114 (x.data.pointer.is_const ? 2749109194 : 4047371087) +
4115 (x.data.pointer.is_volatile ? 536730450 : 1685612214) +
4116 (((uint32_t)x.data.pointer.bit_offset) * 2639019452) +
4117 (((uint32_t)x.data.pointer.unaligned_bit_count) * 529908881);
4118 (x.data.pointer.is_const ? (uint32_t)2749109194 : (uint32_t)4047371087) +
4119 (x.data.pointer.is_volatile ? (uint32_t)536730450 : (uint32_t)1685612214) +
4120 (((uint32_t)x.data.pointer.bit_offset) * (uint32_t)2639019452) +
4121 (((uint32_t)x.data.pointer.unaligned_bit_count) * (uint32_t)529908881);
41184122 case TypeTableEntryIdArray:
41194123 return hash_ptr(x.data.array.child_type) +
4120 (x.data.array.size * 2122979968);
4124 ((uint32_t)x.data.array.size * (uint32_t)2122979968);
41214125 case TypeTableEntryIdInt:
4122 return (x.data.integer.is_signed ? 2652528194 : 163929201) +
4123 (((uint32_t)x.data.integer.bit_count) * 2998081557);
4126 return (x.data.integer.is_signed ? (uint32_t)2652528194 : (uint32_t)163929201) +
4127 (((uint32_t)x.data.integer.bit_count) * (uint32_t)2998081557);
41244128 }
41254129 zig_unreachable();
41264130}
......@@ -4173,13 +4177,13 @@ bool type_id_eql(TypeId a, TypeId b) {
41734177uint32_t zig_llvm_fn_key_hash(ZigLLVMFnKey x) {
41744178 switch (x.id) {
41754179 case ZigLLVMFnIdCtz:
4176 return x.data.ctz.bit_count * 810453934;
4180 return (uint32_t)(x.data.ctz.bit_count) * (uint32_t)810453934;
41774181 case ZigLLVMFnIdClz:
4178 return x.data.clz.bit_count * 2428952817;
4182 return (uint32_t)(x.data.clz.bit_count) * (uint32_t)2428952817;
41794183 case ZigLLVMFnIdOverflowArithmetic:
4180 return (x.data.overflow_arithmetic.bit_count * 87135777) +
4181 (x.data.overflow_arithmetic.add_sub_mul * 31640542) +
4182 (x.data.overflow_arithmetic.is_signed ? 1062315172 : 314955820);
4184 return ((uint32_t)(x.data.overflow_arithmetic.bit_count) * 87135777) +
4185 ((uint32_t)(x.data.overflow_arithmetic.add_sub_mul) * 31640542) +
4186 ((uint32_t)(x.data.overflow_arithmetic.is_signed) ? 1062315172 : 314955820);
41834187 }
41844188 zig_unreachable();
41854189}
src/analyze.hpp+3-3
......@@ -20,8 +20,8 @@ TypeTableEntry *get_pointer_to_type_extra(CodeGen *g, TypeTableEntry *child_type
2020bool is_node_void_expr(AstNode *node);
2121uint64_t type_size(CodeGen *g, TypeTableEntry *type_entry);
2222uint64_t type_size_bits(CodeGen *g, TypeTableEntry *type_entry);
23TypeTableEntry **get_int_type_ptr(CodeGen *g, bool is_signed, uint8_t size_in_bits);
24TypeTableEntry *get_int_type(CodeGen *g, bool is_signed, uint8_t size_in_bits);
23TypeTableEntry **get_int_type_ptr(CodeGen *g, bool is_signed, uint32_t size_in_bits);
24TypeTableEntry *get_int_type(CodeGen *g, bool is_signed, uint32_t size_in_bits);
2525TypeTableEntry **get_c_int_type_ptr(CodeGen *g, CIntType c_int_type);
2626TypeTableEntry *get_c_int_type(CodeGen *g, CIntType c_int_type);
2727TypeTableEntry *get_typedecl_type(CodeGen *g, const char *name, TypeTableEntry *child_type);
......@@ -146,7 +146,7 @@ ConstExprValue *create_const_arg_tuple(CodeGen *g, size_t arg_index_start, size_
146146
147147void init_const_undefined(CodeGen *g, ConstExprValue *const_val);
148148
149TypeTableEntry *make_int_type(CodeGen *g, bool is_signed, size_t size_in_bits);
149TypeTableEntry *make_int_type(CodeGen *g, bool is_signed, uint32_t size_in_bits);
150150ConstParent *get_const_val_parent(ConstExprValue *value);
151151FnTableEntry *get_extern_panic_fn(CodeGen *g);
152152TypeTableEntry *create_enum_tag_type(CodeGen *g, TypeTableEntry *enum_type, TypeTableEntry *int_type);
src/ast_render.cpp+2-2
......@@ -409,8 +409,8 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) {
409409 fprintf(ar->f, "%s%s%sfn ", pub_str, inline_str, extern_str);
410410 print_symbol(ar, node->data.fn_proto.name);
411411 fprintf(ar->f, "(");
412 int arg_count = node->data.fn_proto.params.length;
413 for (int arg_i = 0; arg_i < arg_count; arg_i += 1) {
412 size_t arg_count = node->data.fn_proto.params.length;
413 for (size_t arg_i = 0; arg_i < arg_count; arg_i += 1) {
414414 AstNode *param_decl = node->data.fn_proto.params.at(arg_i);
415415 assert(param_decl->type == NodeTypeParamDecl);
416416 if (buf_len(param_decl->data.param_decl.name) > 0) {
src/bignum.cpp+3-3
......@@ -154,7 +154,7 @@ void bignum_cast_to_float(BigNum *dest, BigNum *op) {
154154 assert(op->kind == BigNumKindInt);
155155 dest->kind = BigNumKindFloat;
156156
157 dest->data.x_float = op->data.x_uint;
157 dest->data.x_float = (double)op->data.x_uint;
158158
159159 if (op->is_negative) {
160160 dest->data.x_float = -dest->data.x_float;
......@@ -166,10 +166,10 @@ void bignum_cast_to_int(BigNum *dest, BigNum *op) {
166166 dest->kind = BigNumKindInt;
167167
168168 if (op->data.x_float >= 0) {
169 dest->data.x_uint = op->data.x_float;
169 dest->data.x_uint = (unsigned long long)op->data.x_float;
170170 dest->is_negative = false;
171171 } else {
172 dest->data.x_uint = -op->data.x_float;
172 dest->data.x_uint = (unsigned long long)-op->data.x_float;
173173 dest->is_negative = true;
174174 }
175175}
src/buffer.hpp+1-1
......@@ -169,7 +169,7 @@ uint32_t buf_hash(Buf *buf);
169169
170170static inline void buf_upcase(Buf *buf) {
171171 for (size_t i = 0; i < buf_len(buf); i += 1) {
172 buf_ptr(buf)[i] = toupper(buf_ptr(buf)[i]);
172 buf_ptr(buf)[i] = (char)toupper(buf_ptr(buf)[i]);
173173 }
174174}
175175
src/c_tokenizer.cpp+3-3
......@@ -548,7 +548,7 @@ void tokenize_c_macro(CTokenize *ctok, const uint8_t *c) {
548548 case '6':
549549 case '7':
550550 ctok->state = CTokStateStrOctal;
551 ctok->cur_char = *c - '0';
551 ctok->cur_char = (uint8_t)(*c - '0');
552552 ctok->octal_index = 1;
553553 break;
554554 case 'x':
......@@ -578,12 +578,12 @@ void tokenize_c_macro(CTokenize *ctok, const uint8_t *c) {
578578 if (((long)ctok->cur_char) * 8 >= 256) {
579579 zig_panic("TODO");
580580 }
581 ctok->cur_char *= 8;
581 ctok->cur_char = (uint8_t)(ctok->cur_char * (uint8_t)8);
582582 // TODO @add_with_overflow
583583 if (((long)ctok->cur_char) + (long)(*c - '0') >= 256) {
584584 zig_panic("TODO");
585585 }
586 ctok->cur_char += *c - '0';
586 ctok->cur_char = (uint8_t)(ctok->cur_char + (uint8_t)(*c - '0'));
587587 ctok->octal_index += 1;
588588 if (ctok->octal_index == 3) {
589589 if (ctok->cur_tok->id == CTokIdStrLit) {
src/codegen.cpp+79-71
......@@ -267,7 +267,7 @@ static void addLLVMAttrStr(LLVMValueRef val, LLVMAttributeIndex attr_index,
267267 const char *attr_name, const char *attr_val)
268268{
269269 LLVMAttributeRef llvm_attr = LLVMCreateStringAttribute(LLVMGetGlobalContext(),
270 attr_name, strlen(attr_name), attr_val, strlen(attr_val));
270 attr_name, (unsigned)strlen(attr_name), attr_val, (unsigned)strlen(attr_val));
271271 LLVMAddAttributeAtIndex(val, attr_index, llvm_attr);
272272}
273273
......@@ -384,7 +384,7 @@ static LLVMValueRef fn_llvm_value(CodeGen *g, FnTableEntry *fn_table_entry) {
384384 LLVMSetSection(fn_table_entry->llvm_value, buf_ptr(fn_table_entry->section_name));
385385 }
386386 if (fn_table_entry->alignment) {
387 LLVMSetAlignment(fn_table_entry->llvm_value, fn_table_entry->alignment);
387 LLVMSetAlignment(fn_table_entry->llvm_value, (unsigned)fn_table_entry->alignment);
388388 }
389389
390390 return fn_table_entry->llvm_value;
......@@ -405,7 +405,7 @@ static ZigLLVMDIScope *get_di_scope(CodeGen *g, Scope *scope) {
405405 FnTableEntry *fn_table_entry = fn_scope->fn_entry;
406406 if (!fn_table_entry->proto_node)
407407 return get_di_scope(g, scope->parent);
408 unsigned line_number = fn_table_entry->proto_node->line + 1;
408 unsigned line_number = (unsigned)fn_table_entry->proto_node->line + 1;
409409 unsigned scope_line = line_number;
410410 bool is_definition = fn_table_entry->body_node != nullptr;
411411 unsigned flags = 0;
......@@ -438,8 +438,8 @@ static ZigLLVMDIScope *get_di_scope(CodeGen *g, Scope *scope) {
438438 ZigLLVMDILexicalBlock *di_block = ZigLLVMCreateLexicalBlock(g->dbuilder,
439439 get_di_scope(g, scope->parent),
440440 import->di_file,
441 scope->source_node->line + 1,
442 scope->source_node->column + 1);
441 (unsigned)scope->source_node->line + 1,
442 (unsigned)scope->source_node->column + 1);
443443 scope->di_scope = ZigLLVMLexicalBlockToScope(di_block);
444444 return scope->di_scope;
445445 }
......@@ -462,7 +462,7 @@ static LLVMValueRef get_arithmetic_overflow_fn(CodeGen *g, TypeTableEntry *type_
462462
463463 assert(type_entry->id == TypeTableEntryIdInt);
464464 const char *signed_str = type_entry->data.integral.is_signed ? signed_name : unsigned_name;
465 sprintf(fn_name, "llvm.%s.with.overflow.i%zu", signed_str, type_entry->data.integral.bit_count);
465 sprintf(fn_name, "llvm.%s.with.overflow.i%" PRIu32, signed_str, type_entry->data.integral.bit_count);
466466
467467 LLVMTypeRef return_elem_types[] = {
468468 type_entry->type_ref,
......@@ -486,7 +486,7 @@ static LLVMValueRef get_int_overflow_fn(CodeGen *g, TypeTableEntry *type_entry,
486486 key.id = ZigLLVMFnIdOverflowArithmetic;
487487 key.data.overflow_arithmetic.is_signed = type_entry->data.integral.is_signed;
488488 key.data.overflow_arithmetic.add_sub_mul = add_sub_mul;
489 key.data.overflow_arithmetic.bit_count = type_entry->data.integral.bit_count;
489 key.data.overflow_arithmetic.bit_count = (uint32_t)type_entry->data.integral.bit_count;
490490
491491 auto existing_entry = g->llvm_fn_table.maybe_get(key);
492492 if (existing_entry)
......@@ -601,8 +601,8 @@ static void gen_panic(CodeGen *g, LLVMValueRef msg_arg) {
601601 TypeTableEntry *str_type = get_slice_type(g, g->builtin_types.entry_u8, true);
602602 size_t ptr_index = str_type->data.structure.fields[slice_ptr_index].gen_index;
603603 size_t len_index = str_type->data.structure.fields[slice_len_index].gen_index;
604 LLVMValueRef ptr_ptr = LLVMBuildStructGEP(g->builder, msg_arg, ptr_index, "");
605 LLVMValueRef len_ptr = LLVMBuildStructGEP(g->builder, msg_arg, len_index, "");
604 LLVMValueRef ptr_ptr = LLVMBuildStructGEP(g->builder, msg_arg, (unsigned)ptr_index, "");
605 LLVMValueRef len_ptr = LLVMBuildStructGEP(g->builder, msg_arg, (unsigned)len_index, "");
606606
607607 LLVMValueRef args[] = {
608608 LLVMBuildLoad(g->builder, ptr_ptr, ""),
......@@ -891,8 +891,8 @@ static LLVMValueRef gen_assign_raw(CodeGen *g, LLVMValueRef ptr, TypeTableEntry
891891
892892static void gen_var_debug_decl(CodeGen *g, VariableTableEntry *var) {
893893 AstNode *source_node = var->decl_node;
894 ZigLLVMDILocation *debug_loc = ZigLLVMGetDebugLoc(source_node->line + 1, source_node->column + 1,
895 get_di_scope(g, var->parent_scope));
894 ZigLLVMDILocation *debug_loc = ZigLLVMGetDebugLoc((unsigned)source_node->line + 1,
895 (unsigned)source_node->column + 1, get_di_scope(g, var->parent_scope));
896896 ZigLLVMInsertDeclareAtEnd(g->dbuilder, var->value_ref, var->di_loc_var, debug_loc,
897897 LLVMGetInsertBlock(g->builder));
898898}
......@@ -1272,20 +1272,20 @@ static LLVMValueRef ir_render_cast(CodeGen *g, IrExecutable *executable,
12721272 TypeTableEntry *wanted_child_type = wanted_pointer_type->data.pointer.child_type;
12731273
12741274
1275 size_t actual_ptr_index = actual_type->data.structure.fields[0].gen_index;
1276 size_t actual_len_index = actual_type->data.structure.fields[1].gen_index;
1277 size_t wanted_ptr_index = wanted_type->data.structure.fields[0].gen_index;
1278 size_t wanted_len_index = wanted_type->data.structure.fields[1].gen_index;
1275 size_t actual_ptr_index = actual_type->data.structure.fields[slice_ptr_index].gen_index;
1276 size_t actual_len_index = actual_type->data.structure.fields[slice_len_index].gen_index;
1277 size_t wanted_ptr_index = wanted_type->data.structure.fields[slice_ptr_index].gen_index;
1278 size_t wanted_len_index = wanted_type->data.structure.fields[slice_len_index].gen_index;
12791279
1280 LLVMValueRef src_ptr_ptr = LLVMBuildStructGEP(g->builder, expr_val, actual_ptr_index, "");
1280 LLVMValueRef src_ptr_ptr = LLVMBuildStructGEP(g->builder, expr_val, (unsigned)actual_ptr_index, "");
12811281 LLVMValueRef src_ptr = LLVMBuildLoad(g->builder, src_ptr_ptr, "");
12821282 LLVMValueRef src_ptr_casted = LLVMBuildBitCast(g->builder, src_ptr,
12831283 wanted_type->data.structure.fields[0].type_entry->type_ref, "");
12841284 LLVMValueRef dest_ptr_ptr = LLVMBuildStructGEP(g->builder, cast_instruction->tmp_ptr,
1285 wanted_ptr_index, "");
1285 (unsigned)wanted_ptr_index, "");
12861286 LLVMBuildStore(g->builder, src_ptr_casted, dest_ptr_ptr);
12871287
1288 LLVMValueRef src_len_ptr = LLVMBuildStructGEP(g->builder, expr_val, actual_len_index, "");
1288 LLVMValueRef src_len_ptr = LLVMBuildStructGEP(g->builder, expr_val, (unsigned)actual_len_index, "");
12891289 LLVMValueRef src_len = LLVMBuildLoad(g->builder, src_len_ptr, "");
12901290 uint64_t src_size = type_size(g, actual_child_type);
12911291 uint64_t dest_size = type_size(g, wanted_child_type);
......@@ -1315,7 +1315,7 @@ static LLVMValueRef ir_render_cast(CodeGen *g, IrExecutable *executable,
13151315 }
13161316
13171317 LLVMValueRef dest_len_ptr = LLVMBuildStructGEP(g->builder, cast_instruction->tmp_ptr,
1318 wanted_len_index, "");
1318 (unsigned)wanted_len_index, "");
13191319 LLVMBuildStore(g->builder, new_len, dest_len_ptr);
13201320
13211321
......@@ -1333,12 +1333,14 @@ static LLVMValueRef ir_render_cast(CodeGen *g, IrExecutable *executable,
13331333
13341334
13351335 size_t wanted_ptr_index = wanted_type->data.structure.fields[0].gen_index;
1336 LLVMValueRef dest_ptr_ptr = LLVMBuildStructGEP(g->builder, cast_instruction->tmp_ptr, wanted_ptr_index, "");
1336 LLVMValueRef dest_ptr_ptr = LLVMBuildStructGEP(g->builder, cast_instruction->tmp_ptr,
1337 (unsigned)wanted_ptr_index, "");
13371338 LLVMValueRef src_ptr_casted = LLVMBuildBitCast(g->builder, expr_val, wanted_pointer_type->type_ref, "");
13381339 LLVMBuildStore(g->builder, src_ptr_casted, dest_ptr_ptr);
13391340
13401341 size_t wanted_len_index = wanted_type->data.structure.fields[1].gen_index;
1341 LLVMValueRef len_ptr = LLVMBuildStructGEP(g->builder, cast_instruction->tmp_ptr, wanted_len_index, "");
1342 LLVMValueRef len_ptr = LLVMBuildStructGEP(g->builder, cast_instruction->tmp_ptr,
1343 (unsigned)wanted_len_index, "");
13421344 LLVMValueRef len_val = LLVMConstInt(g->builtin_types.entry_usize->type_ref,
13431345 actual_type->data.array.len / type_size(g, wanted_child_type), false);
13441346 LLVMBuildStore(g->builder, len_val, len_ptr);
......@@ -1721,14 +1723,14 @@ static LLVMValueRef ir_render_elem_ptr(CodeGen *g, IrExecutable *executable, IrI
17211723 if (safety_check_on) {
17221724 size_t len_index = array_type->data.structure.fields[1].gen_index;
17231725 assert(len_index != SIZE_MAX);
1724 LLVMValueRef len_ptr = LLVMBuildStructGEP(g->builder, array_ptr, len_index, "");
1726 LLVMValueRef len_ptr = LLVMBuildStructGEP(g->builder, array_ptr, (unsigned)len_index, "");
17251727 LLVMValueRef len = LLVMBuildLoad(g->builder, len_ptr, "");
17261728 add_bounds_check(g, subscript_value, LLVMIntEQ, nullptr, LLVMIntULT, len);
17271729 }
17281730
17291731 size_t ptr_index = array_type->data.structure.fields[0].gen_index;
17301732 assert(ptr_index != SIZE_MAX);
1731 LLVMValueRef ptr_ptr = LLVMBuildStructGEP(g->builder, array_ptr, ptr_index, "");
1733 LLVMValueRef ptr_ptr = LLVMBuildStructGEP(g->builder, array_ptr, (unsigned)ptr_index, "");
17321734 LLVMValueRef ptr = LLVMBuildLoad(g->builder, ptr_ptr, "");
17331735 return LLVMBuildInBoundsGEP(g->builder, ptr, &subscript_value, 1, "");
17341736 } else {
......@@ -1772,12 +1774,12 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr
17721774 }
17731775
17741776 LLVMValueRef result = ZigLLVMBuildCall(g->builder, fn_val,
1775 gen_param_values, gen_param_index, fn_type->data.fn.calling_convention, "");
1777 gen_param_values, (unsigned)gen_param_index, fn_type->data.fn.calling_convention, "");
17761778
17771779 for (size_t param_i = 0; param_i < fn_type_id->param_count; param_i += 1) {
17781780 FnGenParamInfo *gen_info = &fn_type->data.fn.gen_param_info[param_i];
17791781 if (gen_info->is_byval) {
1780 addLLVMCallsiteAttr(result, gen_info->gen_index, "byval");
1782 addLLVMCallsiteAttr(result, (unsigned)gen_info->gen_index, "byval");
17811783 }
17821784 }
17831785
......@@ -1810,7 +1812,7 @@ static LLVMValueRef ir_render_struct_field_ptr(CodeGen *g, IrExecutable *executa
18101812 }
18111813
18121814 assert(field->gen_index != SIZE_MAX);
1813 return LLVMBuildStructGEP(g->builder, struct_ptr, field->gen_index, "");
1815 return LLVMBuildStructGEP(g->builder, struct_ptr, (unsigned)field->gen_index, "");
18141816}
18151817
18161818static LLVMValueRef ir_render_enum_field_ptr(CodeGen *g, IrExecutable *executable,
......@@ -1948,14 +1950,14 @@ static LLVMValueRef ir_render_asm(CodeGen *g, IrExecutable *executable, IrInstru
19481950 } else {
19491951 ret_type = instruction->base.value.type->type_ref;
19501952 }
1951 LLVMTypeRef function_type = LLVMFunctionType(ret_type, param_types, input_and_output_count, false);
1953 LLVMTypeRef function_type = LLVMFunctionType(ret_type, param_types, (unsigned)input_and_output_count, false);
19521954
19531955 bool is_x86 = (g->zig_target.arch.arch == ZigLLVM_x86 || g->zig_target.arch.arch == ZigLLVM_x86_64);
19541956 bool is_volatile = asm_expr->is_volatile || (asm_expr->output_list.length == 0);
19551957 LLVMValueRef asm_fn = ZigLLVMConstInlineAsm(function_type, buf_ptr(&llvm_template),
19561958 buf_ptr(&constraint_buf), is_volatile, false, is_x86);
19571959
1958 return LLVMBuildCall(g->builder, asm_fn, param_values, input_and_output_count, "");
1960 return LLVMBuildCall(g->builder, asm_fn, param_values, (unsigned)input_and_output_count, "");
19591961}
19601962
19611963static LLVMValueRef gen_non_null_bit(CodeGen *g, TypeTableEntry *maybe_type, LLVMValueRef maybe_handle) {
......@@ -2021,11 +2023,11 @@ static LLVMValueRef get_int_builtin_fn(CodeGen *g, TypeTableEntry *int_type, Bui
20212023 if (fn_id == BuiltinFnIdCtz) {
20222024 fn_name = "cttz";
20232025 key.id = ZigLLVMFnIdCtz;
2024 key.data.ctz.bit_count = int_type->data.integral.bit_count;
2026 key.data.ctz.bit_count = (uint32_t)int_type->data.integral.bit_count;
20252027 } else {
20262028 fn_name = "ctlz";
20272029 key.id = ZigLLVMFnIdClz;
2028 key.data.clz.bit_count = int_type->data.integral.bit_count;
2030 key.data.clz.bit_count = (uint32_t)int_type->data.integral.bit_count;
20292031 }
20302032
20312033 auto existing_entry = g->llvm_fn_table.maybe_get(key);
......@@ -2033,7 +2035,7 @@ static LLVMValueRef get_int_builtin_fn(CodeGen *g, TypeTableEntry *int_type, Bui
20332035 return existing_entry->value;
20342036
20352037 char llvm_name[64];
2036 sprintf(llvm_name, "llvm.%s.i%zu", fn_name, int_type->data.integral.bit_count);
2038 sprintf(llvm_name, "llvm.%s.i%" PRIu32, fn_name, int_type->data.integral.bit_count);
20372039 LLVMTypeRef param_types[] = {
20382040 int_type->type_ref,
20392041 LLVMInt1Type(),
......@@ -2071,7 +2073,8 @@ static LLVMValueRef ir_render_ctz(CodeGen *g, IrExecutable *executable, IrInstru
20712073static LLVMValueRef ir_render_switch_br(CodeGen *g, IrExecutable *executable, IrInstructionSwitchBr *instruction) {
20722074 LLVMValueRef target_value = ir_llvm_value(g, instruction->target_value);
20732075 LLVMBasicBlockRef else_block = instruction->else_block->llvm_block;
2074 LLVMValueRef switch_instr = LLVMBuildSwitch(g->builder, target_value, else_block, instruction->case_count);
2076 LLVMValueRef switch_instr = LLVMBuildSwitch(g->builder, target_value, else_block,
2077 (unsigned)instruction->case_count);
20752078 for (size_t i = 0; i < instruction->case_count; i += 1) {
20762079 IrInstructionSwitchBrCase *this_case = &instruction->cases[i];
20772080 LLVMAddCase(switch_instr, ir_llvm_value(g, this_case->value), this_case->block->llvm_block);
......@@ -2097,7 +2100,7 @@ static LLVMValueRef ir_render_phi(CodeGen *g, IrExecutable *executable, IrInstru
20972100 incoming_values[i] = ir_llvm_value(g, instruction->incoming_values[i]);
20982101 incoming_blocks[i] = instruction->incoming_blocks[i]->llvm_exit_block;
20992102 }
2100 LLVMAddIncoming(phi, incoming_values, incoming_blocks, instruction->incoming_count);
2103 LLVMAddIncoming(phi, incoming_values, incoming_blocks, (unsigned)instruction->incoming_count);
21012104 return phi;
21022105}
21032106
......@@ -2337,14 +2340,14 @@ static LLVMValueRef ir_render_slice(CodeGen *g, IrExecutable *executable, IrInst
23372340 assert(LLVMGetTypeKind(LLVMTypeOf(array_ptr)) == LLVMPointerTypeKind);
23382341 assert(LLVMGetTypeKind(LLVMGetElementType(LLVMTypeOf(array_ptr))) == LLVMStructTypeKind);
23392342
2340 size_t ptr_index = array_type->data.structure.fields[0].gen_index;
2343 size_t ptr_index = array_type->data.structure.fields[slice_ptr_index].gen_index;
23412344 assert(ptr_index != SIZE_MAX);
2342 size_t len_index = array_type->data.structure.fields[1].gen_index;
2345 size_t len_index = array_type->data.structure.fields[slice_len_index].gen_index;
23432346 assert(len_index != SIZE_MAX);
23442347
23452348 LLVMValueRef prev_end = nullptr;
23462349 if (!instruction->end || want_debug_safety) {
2347 LLVMValueRef src_len_ptr = LLVMBuildStructGEP(g->builder, array_ptr, len_index, "");
2350 LLVMValueRef src_len_ptr = LLVMBuildStructGEP(g->builder, array_ptr, (unsigned)len_index, "");
23482351 prev_end = LLVMBuildLoad(g->builder, src_len_ptr, "");
23492352 }
23502353
......@@ -2364,13 +2367,13 @@ static LLVMValueRef ir_render_slice(CodeGen *g, IrExecutable *executable, IrInst
23642367 }
23652368 }
23662369
2367 LLVMValueRef src_ptr_ptr = LLVMBuildStructGEP(g->builder, array_ptr, ptr_index, "");
2370 LLVMValueRef src_ptr_ptr = LLVMBuildStructGEP(g->builder, array_ptr, (unsigned)ptr_index, "");
23682371 LLVMValueRef src_ptr = LLVMBuildLoad(g->builder, src_ptr_ptr, "");
2369 LLVMValueRef ptr_field_ptr = LLVMBuildStructGEP(g->builder, tmp_struct_ptr, ptr_index, "");
2370 LLVMValueRef slice_start_ptr = LLVMBuildInBoundsGEP(g->builder, src_ptr, &start_val, len_index, "");
2372 LLVMValueRef ptr_field_ptr = LLVMBuildStructGEP(g->builder, tmp_struct_ptr, (unsigned)ptr_index, "");
2373 LLVMValueRef slice_start_ptr = LLVMBuildInBoundsGEP(g->builder, src_ptr, &start_val, (unsigned)len_index, "");
23712374 LLVMBuildStore(g->builder, slice_start_ptr, ptr_field_ptr);
23722375
2373 LLVMValueRef len_field_ptr = LLVMBuildStructGEP(g->builder, tmp_struct_ptr, len_index, "");
2376 LLVMValueRef len_field_ptr = LLVMBuildStructGEP(g->builder, tmp_struct_ptr, (unsigned)len_index, "");
23742377 LLVMValueRef len_value = LLVMBuildNSWSub(g->builder, end_val, start_val, "");
23752378 LLVMBuildStore(g->builder, len_value, len_field_ptr);
23762379
......@@ -2650,12 +2653,13 @@ static LLVMValueRef ir_render_struct_init(CodeGen *g, IrExecutable *executable,
26502653 if (!type_has_bits(type_struct_field->type_entry))
26512654 continue;
26522655
2653 LLVMValueRef field_ptr = LLVMBuildStructGEP(g->builder, instruction->tmp_ptr, type_struct_field->gen_index, "");
2656 LLVMValueRef field_ptr = LLVMBuildStructGEP(g->builder, instruction->tmp_ptr,
2657 (unsigned)type_struct_field->gen_index, "");
26542658 LLVMValueRef value = ir_llvm_value(g, field->value);
26552659
26562660 TypeTableEntry *ptr_type = get_pointer_to_type_extra(g, type_struct_field->type_entry,
26572661 false, false,
2658 type_struct_field->packed_bits_offset, type_struct_field->unaligned_bit_count);
2662 (uint32_t)type_struct_field->packed_bits_offset, (uint32_t)type_struct_field->unaligned_bit_count);
26592663
26602664 gen_assign_raw(g, field_ptr, ptr_type, value);
26612665 }
......@@ -2698,7 +2702,8 @@ static void set_debug_location(CodeGen *g, IrInstruction *instruction) {
26982702 assert(source_node);
26992703 assert(scope);
27002704
2701 ZigLLVMSetCurrentDebugLocation(g->builder, source_node->line + 1, source_node->column + 1, get_di_scope(g, scope));
2705 ZigLLVMSetCurrentDebugLocation(g->builder, (int)source_node->line + 1,
2706 (int)source_node->column + 1, get_di_scope(g, scope));
27022707}
27032708
27042709static LLVMValueRef ir_render_instruction(CodeGen *g, IrExecutable *executable, IrInstruction *instruction) {
......@@ -2964,7 +2969,8 @@ static LLVMValueRef pack_const_int(CodeGen *g, LLVMTypeRef big_int_type_ref, Con
29642969 case TypeTableEntryIdFloat:
29652970 {
29662971 LLVMValueRef float_val = gen_const_val(g, const_val);
2967 LLVMValueRef int_val = LLVMConstFPToUI(float_val, LLVMIntType(canon_type->data.floating.bit_count));
2972 LLVMValueRef int_val = LLVMConstFPToUI(float_val,
2973 LLVMIntType((unsigned)canon_type->data.floating.bit_count));
29682974 return LLVMConstZExt(int_val, big_int_type_ref);
29692975 }
29702976 case TypeTableEntryIdPointer:
......@@ -3027,7 +3033,7 @@ static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val) {
30273033 if (const_val->data.x_bignum.kind == BigNumKindFloat) {
30283034 return LLVMConstReal(canon_type->type_ref, const_val->data.x_bignum.data.x_float);
30293035 } else {
3030 int64_t x = const_val->data.x_bignum.data.x_uint;
3036 double x = (double)const_val->data.x_bignum.data.x_uint;
30313037 if (const_val->data.x_bignum.is_negative) {
30323038 x = -x;
30333039 }
......@@ -3094,7 +3100,7 @@ static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val) {
30943100 gen_const_val(g, &const_val->data.x_struct.fields[src_field_index]);
30953101 } else {
30963102 LLVMTypeRef big_int_type_ref = LLVMStructGetTypeAtIndex(canon_type->type_ref,
3097 type_struct_field->gen_index);
3103 (unsigned)type_struct_field->gen_index);
30983104 LLVMValueRef val = LLVMConstInt(big_int_type_ref, 0, false);
30993105 for (size_t i = src_field_index; i < src_field_index_end; i += 1) {
31003106 TypeStructField *it_field = &canon_type->data.structure.fields[i];
......@@ -3136,7 +3142,7 @@ static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val) {
31363142 ConstExprValue *elem_value = &const_val->data.x_array.elements[i];
31373143 values[i] = gen_const_val(g, elem_value);
31383144 }
3139 return LLVMConstArray(LLVMTypeOf(values[0]), values, len);
3145 return LLVMConstArray(LLVMTypeOf(values[0]), values, (unsigned)len);
31403146 }
31413147 case TypeTableEntryIdEnum:
31423148 {
......@@ -3162,7 +3168,7 @@ static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val) {
31623168 } else {
31633169 LLVMValueRef fields[] = {
31643170 correctly_typed_value,
3165 LLVMGetUndef(LLVMArrayType(LLVMInt8Type(), pad_bytes)),
3171 LLVMGetUndef(LLVMArrayType(LLVMInt8Type(), (unsigned)pad_bytes)),
31663172 };
31673173 union_value = LLVMConstStruct(fields, 2, false);
31683174 }
......@@ -3352,7 +3358,7 @@ static bool should_skip_fn_codegen(CodeGen *g, FnTableEntry *fn_entry) {
33523358static LLVMValueRef gen_test_fn_val(CodeGen *g, FnTableEntry *fn_entry) {
33533359 // Must match TestFn struct from test_runner.zig
33543360 Buf *fn_name = &fn_entry->symbol_name;
3355 LLVMValueRef str_init = LLVMConstString(buf_ptr(fn_name), buf_len(fn_name), true);
3361 LLVMValueRef str_init = LLVMConstString(buf_ptr(fn_name), (unsigned)buf_len(fn_name), true);
33563362 LLVMValueRef str_global_val = LLVMAddGlobal(g->module, LLVMTypeOf(str_init), "");
33573363 LLVMSetInitializer(str_global_val, str_init);
33583364 LLVMSetLinkage(str_global_val, LLVMPrivateLinkage);
......@@ -3392,7 +3398,7 @@ static void generate_error_name_table(CodeGen *g) {
33923398 assert(error_decl_node->type == NodeTypeErrorValueDecl);
33933399 Buf *name = error_decl_node->data.error_value_decl.name;
33943400
3395 LLVMValueRef str_init = LLVMConstString(buf_ptr(name), buf_len(name), true);
3401 LLVMValueRef str_init = LLVMConstString(buf_ptr(name), (unsigned)buf_len(name), true);
33963402 LLVMValueRef str_global = LLVMAddGlobal(g->module, LLVMTypeOf(str_init), "");
33973403 LLVMSetInitializer(str_global, str_init);
33983404 LLVMSetLinkage(str_global, LLVMPrivateLinkage);
......@@ -3406,7 +3412,7 @@ static void generate_error_name_table(CodeGen *g) {
34063412 values[i] = LLVMConstNamedStruct(str_type->type_ref, fields, 2);
34073413 }
34083414
3409 LLVMValueRef err_name_table_init = LLVMConstArray(str_type->type_ref, values, g->error_decls.length);
3415 LLVMValueRef err_name_table_init = LLVMConstArray(str_type->type_ref, values, (unsigned)g->error_decls.length);
34103416
34113417 g->err_name_table = LLVMAddGlobal(g->module, LLVMTypeOf(err_name_table_init),
34123418 buf_ptr(get_mangled_name(g, buf_create_from_str("err_name_table"), false)));
......@@ -3430,7 +3436,7 @@ static void generate_enum_name_tables(CodeGen *g) {
34303436 for (size_t field_i = 0; field_i < field_count; field_i += 1) {
34313437 Buf *name = enum_type->data.enumeration.fields[field_i].name;
34323438
3433 LLVMValueRef str_init = LLVMConstString(buf_ptr(name), buf_len(name), true);
3439 LLVMValueRef str_init = LLVMConstString(buf_ptr(name), (unsigned)buf_len(name), true);
34343440 LLVMValueRef str_global = LLVMAddGlobal(g->module, LLVMTypeOf(str_init), "");
34353441 LLVMSetInitializer(str_global, str_init);
34363442 LLVMSetLinkage(str_global, LLVMPrivateLinkage);
......@@ -3444,7 +3450,7 @@ static void generate_enum_name_tables(CodeGen *g) {
34443450 values[field_i] = LLVMConstNamedStruct(str_type->type_ref, fields, 2);
34453451 }
34463452
3447 LLVMValueRef name_table_init = LLVMConstArray(str_type->type_ref, values, field_count);
3453 LLVMValueRef name_table_init = LLVMConstArray(str_type->type_ref, values, (unsigned)field_count);
34483454
34493455 Buf *table_name = get_mangled_name(g, buf_sprintf("%s_name_table", buf_ptr(&enum_type->name)), false);
34503456 LLVMValueRef name_table = LLVMAddGlobal(g->module, LLVMTypeOf(name_table_init), buf_ptr(table_name));
......@@ -3478,7 +3484,8 @@ static void gen_global_var(CodeGen *g, VariableTableEntry *var, LLVMValueRef ini
34783484
34793485 bool is_local_to_unit = true;
34803486 ZigLLVMCreateGlobalVariable(g->dbuilder, get_di_scope(g, var->parent_scope), buf_ptr(&var->name),
3481 buf_ptr(&var->name), import->di_file, var->decl_node->line + 1,
3487 buf_ptr(&var->name), import->di_file,
3488 (unsigned)(var->decl_node->line + 1),
34823489 type_entry->di_type, is_local_to_unit);
34833490 // TODO ^^ make an actual global variable
34843491}
......@@ -3606,16 +3613,16 @@ static void do_code_gen(CodeGen *g) {
36063613
36073614 TypeTableEntry *param_type = gen_info->type;
36083615 if (param_info->is_noalias) {
3609 addLLVMArgAttr(fn_val, gen_index, "noalias");
3616 addLLVMArgAttr(fn_val, (unsigned)gen_index, "noalias");
36103617 }
36113618 if ((param_type->id == TypeTableEntryIdPointer && param_type->data.pointer.is_const) || is_byval) {
3612 addLLVMArgAttr(fn_val, gen_index, "readonly");
3619 addLLVMArgAttr(fn_val, (unsigned)gen_index, "readonly");
36133620 }
36143621 if (param_type->id == TypeTableEntryIdPointer) {
3615 addLLVMArgAttr(fn_val, gen_index, "nonnull");
3622 addLLVMArgAttr(fn_val, (unsigned)gen_index, "nonnull");
36163623 }
36173624 if (is_byval) {
3618 addLLVMArgAttr(fn_val, gen_index, "byval");
3625 addLLVMArgAttr(fn_val, (unsigned)gen_index, "byval");
36193626 }
36203627 }
36213628
......@@ -3737,7 +3744,7 @@ static void do_code_gen(CodeGen *g) {
37373744 var->value_ref = build_alloca(g, var->value->type, buf_ptr(&var->name));
37383745
37393746 var->di_loc_var = ZigLLVMCreateAutoVariable(g->dbuilder, get_di_scope(g, var->parent_scope),
3740 buf_ptr(&var->name), import->di_file, var->decl_node->line + 1,
3747 buf_ptr(&var->name), import->di_file, (unsigned)(var->decl_node->line + 1),
37413748 var->value->type->di_type, !g->strip_debug_symbols, 0);
37423749
37433750 } else {
......@@ -3751,15 +3758,16 @@ static void do_code_gen(CodeGen *g) {
37513758 } else {
37523759 gen_type = gen_info->type;
37533760 }
3754 var->value_ref = LLVMGetParam(fn, var->gen_arg_index);
3761 var->value_ref = LLVMGetParam(fn, (unsigned)var->gen_arg_index);
37553762 } else {
37563763 gen_type = var->value->type;
37573764 var->value_ref = build_alloca(g, var->value->type, buf_ptr(&var->name));
37583765 }
37593766 if (var->decl_node) {
37603767 var->di_loc_var = ZigLLVMCreateParameterVariable(g->dbuilder, get_di_scope(g, var->parent_scope),
3761 buf_ptr(&var->name), import->di_file, var->decl_node->line + 1,
3762 gen_type->di_type, !g->strip_debug_symbols, 0, var->gen_arg_index + 1);
3768 buf_ptr(&var->name), import->di_file,
3769 (unsigned)(var->decl_node->line + 1),
3770 gen_type->di_type, !g->strip_debug_symbols, 0, (unsigned)(var->gen_arg_index + 1));
37633771 }
37643772
37653773 }
......@@ -3784,7 +3792,7 @@ static void do_code_gen(CodeGen *g) {
37843792
37853793 if (!handle_is_ptr(variable->value->type)) {
37863794 clear_debug_source_node(g);
3787 LLVMBuildStore(g->builder, LLVMGetParam(fn, variable->gen_arg_index), variable->value_ref);
3795 LLVMBuildStore(g->builder, LLVMGetParam(fn, (unsigned)variable->gen_arg_index), variable->value_ref);
37883796 }
37893797
37903798 if (variable->decl_node) {
......@@ -3827,7 +3835,7 @@ static void do_code_gen(CodeGen *g) {
38273835 g->link_objects.append(out_file_o);
38283836}
38293837
3830static const size_t int_sizes_in_bits[] = {
3838static const uint8_t int_sizes_in_bits[] = {
38313839 8,
38323840 16,
38333841 32,
......@@ -3950,7 +3958,7 @@ static void define_builtin_types(CodeGen *g) {
39503958 }
39513959
39523960 for (size_t int_size_i = 0; int_size_i < array_length(int_sizes_in_bits); int_size_i += 1) {
3953 size_t size_in_bits = int_sizes_in_bits[int_size_i];
3961 uint8_t size_in_bits = int_sizes_in_bits[int_size_i];
39543962 for (size_t is_sign_i = 0; is_sign_i < array_length(is_signed_list); is_sign_i += 1) {
39553963 bool is_signed = is_signed_list[is_sign_i];
39563964 TypeTableEntry *entry = make_int_type(g, is_signed, size_in_bits);
......@@ -3961,7 +3969,7 @@ static void define_builtin_types(CodeGen *g) {
39613969
39623970 for (size_t i = 0; i < array_length(c_int_type_infos); i += 1) {
39633971 const CIntTypeInfo *info = &c_int_type_infos[i];
3964 uint64_t size_in_bits = get_c_type_size_in_bits(&g->zig_target, info->id);
3972 uint32_t size_in_bits = target_c_type_size_in_bits(&g->zig_target, info->id);
39653973 bool is_signed = info->is_signed;
39663974
39673975 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdInt);
......@@ -4116,7 +4124,7 @@ static void define_builtin_types(CodeGen *g) {
41164124 {
41174125 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdEnum);
41184126 buf_init_from_str(&entry->name, "Os");
4119 uint32_t field_count = target_os_count();
4127 uint32_t field_count = (uint32_t)target_os_count();
41204128 entry->data.enumeration.src_field_count = field_count;
41214129 entry->data.enumeration.fields = allocate<TypeEnumField>(field_count);
41224130 for (uint32_t i = 0; i < field_count; i += 1) {
......@@ -4140,7 +4148,7 @@ static void define_builtin_types(CodeGen *g) {
41404148 {
41414149 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdEnum);
41424150 buf_init_from_str(&entry->name, "Arch");
4143 uint32_t field_count = target_arch_count();
4151 uint32_t field_count = (uint32_t)target_arch_count();
41444152 entry->data.enumeration.src_field_count = field_count;
41454153 entry->data.enumeration.fields = allocate<TypeEnumField>(field_count);
41464154 for (uint32_t i = 0; i < field_count; i += 1) {
......@@ -4170,7 +4178,7 @@ static void define_builtin_types(CodeGen *g) {
41704178 {
41714179 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdEnum);
41724180 buf_init_from_str(&entry->name, "Environ");
4173 uint32_t field_count = target_environ_count();
4181 uint32_t field_count = (uint32_t)target_environ_count();
41744182 entry->data.enumeration.src_field_count = field_count;
41754183 entry->data.enumeration.fields = allocate<TypeEnumField>(field_count);
41764184 for (uint32_t i = 0; i < field_count; i += 1) {
......@@ -4194,7 +4202,7 @@ static void define_builtin_types(CodeGen *g) {
41944202 {
41954203 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdEnum);
41964204 buf_init_from_str(&entry->name, "ObjectFormat");
4197 uint32_t field_count = target_oformat_count();
4205 uint32_t field_count = (uint32_t)target_oformat_count();
41984206 entry->data.enumeration.src_field_count = field_count;
41994207 entry->data.enumeration.fields = allocate<TypeEnumField>(field_count);
42004208 for (uint32_t i = 0; i < field_count; i += 1) {
......@@ -4705,7 +4713,7 @@ static void get_c_type(CodeGen *g, TypeTableEntry *type_entry, Buf *out_buf) {
47054713 case TypeTableEntryIdInt:
47064714 g->c_want_stdint = true;
47074715 buf_resize(out_buf, 0);
4708 buf_appendf(out_buf, "%sint%zu_t",
4716 buf_appendf(out_buf, "%sint%" PRIu32 "_t",
47094717 type_entry->data.integral.is_signed ? "" : "u",
47104718 type_entry->data.integral.bit_count);
47114719 break;
src/ir.cpp+7-6
......@@ -7295,7 +7295,7 @@ static Buf *ir_resolve_str(IrAnalyze *ira, IrInstruction *value) {
72957295 ConstExprValue *char_val = &array_val->data.x_array.elements[new_index];
72967296 uint64_t big_c = char_val->data.x_bignum.data.x_uint;
72977297 assert(big_c <= UINT8_MAX);
7298 uint8_t c = big_c;
7298 uint8_t c = (uint8_t)big_c;
72997299 buf_ptr(result)[i] = c;
73007300 }
73017301 return result;
......@@ -9062,7 +9062,7 @@ static TypeTableEntry *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruc
90629062
90639063 return_type = get_pointer_to_type_extra(ira->codegen, child_type,
90649064 ptr_type->data.pointer.is_const, ptr_type->data.pointer.is_volatile,
9065 bit_offset, bit_width);
9065 (uint32_t)bit_offset, (uint32_t)bit_width);
90669066 }
90679067 } else if (array_type->id == TypeTableEntryIdPointer) {
90689068 return_type = array_type;
......@@ -9299,7 +9299,8 @@ static TypeTableEntry *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field
92999299 field->unaligned_bit_count : type_size_bits(ira->codegen, field->type_entry);
93009300 ir_build_struct_field_ptr_from(&ira->new_irb, &field_ptr_instruction->base, container_ptr, field);
93019301 return get_pointer_to_type_extra(ira->codegen, field->type_entry, is_const, is_volatile,
9302 ptr_bit_offset + field->packed_bits_offset, unaligned_bit_count_for_result_type);
9302 (uint32_t)(ptr_bit_offset + field->packed_bits_offset),
9303 (uint32_t)unaligned_bit_count_for_result_type);
93039304 } else {
93049305 return ir_analyze_container_member_access_inner(ira, bare_type, field_name,
93059306 field_ptr_instruction, container_ptr, container_type);
......@@ -9759,7 +9760,7 @@ static TypeTableEntry *ir_analyze_instruction_set_global_align(IrAnalyze *ira,
97599760 }
97609761
97619762 AstNode **set_global_align_node;
9762 uint64_t *alignment_ptr;
9763 uint32_t *alignment_ptr;
97639764 if (tld->id == TldIdVar) {
97649765 TldVar *tld_var = (TldVar *)tld;
97659766 set_global_align_node = &tld_var->set_global_align_node;
......@@ -9782,7 +9783,7 @@ static TypeTableEntry *ir_analyze_instruction_set_global_align(IrAnalyze *ira,
97829783 return ira->codegen->builtin_types.entry_invalid;
97839784 }
97849785 *set_global_align_node = source_node;
9785 *alignment_ptr = scalar_align;
9786 *alignment_ptr = (uint32_t)scalar_align;
97869787
97879788 ir_build_const_from(ira, &instruction->base);
97889789 return ira->codegen->builtin_types.entry_void;
......@@ -11547,7 +11548,7 @@ static TypeTableEntry *ir_analyze_instruction_int_type(IrAnalyze *ira, IrInstruc
1154711548 return ira->codegen->builtin_types.entry_invalid;
1154811549
1154911550 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
11550 out_val->data.x_type = get_int_type(ira->codegen, is_signed, bit_count);
11551 out_val->data.x_type = get_int_type(ira->codegen, is_signed, (uint32_t)bit_count);
1155111552 return ira->codegen->builtin_types.entry_type;
1155211553}
1155311554
src/link.cpp+3-3
......@@ -503,21 +503,21 @@ static bool darwin_get_release_version(const char *str, int *major, int *minor,
503503 return false;
504504
505505 char *end;
506 *major = strtol(str, &end, 10);
506 *major = (int)strtol(str, &end, 10);
507507 if (*str != '\0' && *end == '\0')
508508 return true;
509509 if (*end != '.')
510510 return false;
511511
512512 str = end + 1;
513 *minor = strtol(str, &end, 10);
513 *minor = (int)strtol(str, &end, 10);
514514 if (*str != '\0' && *end == '\0')
515515 return true;
516516 if (*end != '.')
517517 return false;
518518
519519 str = end + 1;
520 *micro = strtol(str, &end, 10);
520 *micro = (int)strtol(str, &end, 10);
521521 if (*str != '\0' && *end == '\0')
522522 return true;
523523 if (str == end)
src/list.hpp+1-1
......@@ -69,7 +69,7 @@ struct ZigList {
6969
7070 size_t better_capacity = capacity;
7171 do {
72 better_capacity = better_capacity * 1.4 + 8;
72 better_capacity = better_capacity * 5 / 2 + 8;
7373 } while (better_capacity < new_capacity);
7474
7575 items = reallocate_nonzero(items, capacity, better_capacity);
src/os.cpp+2-2
......@@ -556,7 +556,7 @@ static int os_buf_to_tmp_file_posix(Buf *contents, Buf *suffix, Buf *out_tmp_pat
556556 buf_resize(out_tmp_path, 0);
557557 buf_appendf(out_tmp_path, "%s/XXXXXX%s", tmp_dir, buf_ptr(suffix));
558558
559 int fd = mkstemps(buf_ptr(out_tmp_path), buf_len(suffix));
559 int fd = mkstemps(buf_ptr(out_tmp_path), (int)buf_len(suffix));
560560 if (fd < 0) {
561561 return ErrorFileSystem;
562562 }
......@@ -629,5 +629,5 @@ int os_delete_file(Buf *path) {
629629}
630630
631631void os_init(void) {
632 srand(time(NULL));
632 srand((unsigned)time(NULL));
633633}
src/target.cpp+6-6
......@@ -161,7 +161,7 @@ size_t target_oformat_count(void) {
161161 return array_length(oformat_list);
162162}
163163
164const ZigLLVM_ObjectFormatType get_target_oformat(int index) {
164const ZigLLVM_ObjectFormatType get_target_oformat(size_t index) {
165165 return oformat_list[index];
166166}
167167
......@@ -179,7 +179,7 @@ size_t target_arch_count(void) {
179179 return array_length(arch_list);
180180}
181181
182const ArchType *get_target_arch(int index) {
182const ArchType *get_target_arch(size_t index) {
183183 return &arch_list[index];
184184}
185185
......@@ -187,14 +187,14 @@ size_t target_vendor_count(void) {
187187 return array_length(vendor_list);
188188}
189189
190ZigLLVM_VendorType get_target_vendor(int index) {
190ZigLLVM_VendorType get_target_vendor(size_t index) {
191191 return vendor_list[index];
192192}
193193
194194size_t target_os_count(void) {
195195 return array_length(os_list);
196196}
197ZigLLVM_OSType get_target_os(int index) {
197ZigLLVM_OSType get_target_os(size_t index) {
198198 return os_list[index];
199199}
200200
......@@ -205,7 +205,7 @@ const char *get_target_os_name(ZigLLVM_OSType os_type) {
205205size_t target_environ_count(void) {
206206 return array_length(environ_list);
207207}
208ZigLLVM_EnvironmentType get_target_environ(int index) {
208ZigLLVM_EnvironmentType get_target_environ(size_t index) {
209209 return environ_list[index];
210210}
211211
......@@ -443,7 +443,7 @@ static int get_arch_pointer_bit_width(ZigLLVM_ArchType arch) {
443443 zig_unreachable();
444444}
445445
446int get_c_type_size_in_bits(const ZigTarget *target, CIntType id) {
446uint32_t target_c_type_size_in_bits(const ZigTarget *target, CIntType id) {
447447 switch (target->os) {
448448 case ZigLLVM_UnknownOS:
449449 switch (id) {
src/target.hpp+6-6
......@@ -39,22 +39,22 @@ enum CIntType {
3939};
4040
4141size_t target_arch_count(void);
42const ArchType *get_target_arch(int index);
42const ArchType *get_target_arch(size_t index);
4343void get_arch_name(char *out_str, const ArchType *arch);
4444
4545size_t target_vendor_count(void);
46ZigLLVM_VendorType get_target_vendor(int index);
46ZigLLVM_VendorType get_target_vendor(size_t index);
4747
4848size_t target_os_count(void);
49ZigLLVM_OSType get_target_os(int index);
49ZigLLVM_OSType get_target_os(size_t index);
5050const char *get_target_os_name(ZigLLVM_OSType os_type);
5151
5252size_t target_environ_count(void);
53ZigLLVM_EnvironmentType get_target_environ(int index);
53ZigLLVM_EnvironmentType get_target_environ(size_t index);
5454
5555
5656size_t target_oformat_count(void);
57const ZigLLVM_ObjectFormatType get_target_oformat(int index);
57const ZigLLVM_ObjectFormatType get_target_oformat(size_t index);
5858const char *get_target_oformat_name(ZigLLVM_ObjectFormatType oformat);
5959
6060void get_native_target(ZigTarget *target);
......@@ -70,7 +70,7 @@ void get_target_triple(Buf *triple, const ZigTarget *target);
7070
7171void resolve_target_object_format(ZigTarget *target);
7272
73int get_c_type_size_in_bits(const ZigTarget *target, CIntType id);
73uint32_t target_c_type_size_in_bits(const ZigTarget *target, CIntType id);
7474
7575const char *target_o_file_ext(ZigTarget *target);
7676
src/tokenizer.cpp+16-16
......@@ -309,7 +309,7 @@ static void end_float_token(Tokenize *t) {
309309 if (t->is_exp_negative) {
310310 specified_exponent = -specified_exponent;
311311 }
312 t->exponent_in_bin_or_dec += specified_exponent;
312 t->exponent_in_bin_or_dec = (int)(t->exponent_in_bin_or_dec + specified_exponent);
313313
314314 uint64_t significand = t->cur_tok->data.num_lit.bignum.data.x_uint;
315315 uint64_t significand_bits;
......@@ -352,7 +352,7 @@ static void end_token(Tokenize *t) {
352352 }
353353 } else if (t->cur_tok->id == TokenIdSymbol) {
354354 char *token_mem = buf_ptr(t->buf) + t->cur_tok->start_pos;
355 int token_len = t->cur_tok->end_pos - t->cur_tok->start_pos;
355 int token_len = (int)(t->cur_tok->end_pos - t->cur_tok->start_pos);
356356
357357 for (size_t i = 0; i < array_length(zig_keywords); i += 1) {
358358 if (mem_eql_str(token_mem, token_len, zig_keywords[i].text)) {
......@@ -1088,39 +1088,39 @@ void tokenize(Buf *buf, Tokenization *out) {
10881088 if (t.unicode) {
10891089 if (t.char_code <= 0x7f) {
10901090 // 00000000 00000000 00000000 0xxxxxxx
1091 handle_string_escape(&t, t.char_code);
1091 handle_string_escape(&t, (uint8_t)t.char_code);
10921092 } else if (t.cur_tok->id == TokenIdCharLiteral) {
10931093 tokenize_error(&t, "unicode value too large for character literal: %x", t.char_code);
10941094 } else if (t.char_code <= 0x7ff) {
10951095 // 00000000 00000000 00000xxx xx000000
1096 handle_string_escape(&t, 0xc0 | (t.char_code >> 6));
1096 handle_string_escape(&t, (uint8_t)(0xc0 | (t.char_code >> 6)));
10971097 // 00000000 00000000 00000000 00xxxxxx
1098 handle_string_escape(&t, 0x80 | (t.char_code & 0x3f));
1098 handle_string_escape(&t, (uint8_t)(0x80 | (t.char_code & 0x3f)));
10991099 } else if (t.char_code <= 0xffff) {
11001100 // 00000000 00000000 xxxx0000 00000000
1101 handle_string_escape(&t, 0xe0 | (t.char_code >> 12));
1101 handle_string_escape(&t, (uint8_t)(0xe0 | (t.char_code >> 12)));
11021102 // 00000000 00000000 0000xxxx xx000000
1103 handle_string_escape(&t, 0x80 | ((t.char_code >> 6) & 0x3f));
1103 handle_string_escape(&t, (uint8_t)(0x80 | ((t.char_code >> 6) & 0x3f)));
11041104 // 00000000 00000000 00000000 00xxxxxx
1105 handle_string_escape(&t, 0x80 | (t.char_code & 0x3f));
1105 handle_string_escape(&t, (uint8_t)(0x80 | (t.char_code & 0x3f)));
11061106 } else if (t.char_code <= 0x10ffff) {
11071107 // 00000000 000xxx00 00000000 00000000
1108 handle_string_escape(&t, 0xf0 | (t.char_code >> 18));
1108 handle_string_escape(&t, (uint8_t)(0xf0 | (t.char_code >> 18)));
11091109 // 00000000 000000xx xxxx0000 00000000
1110 handle_string_escape(&t, 0x80 | ((t.char_code >> 12) & 0x3f));
1110 handle_string_escape(&t, (uint8_t)(0x80 | ((t.char_code >> 12) & 0x3f)));
11111111 // 00000000 00000000 0000xxxx xx000000
1112 handle_string_escape(&t, 0x80 | ((t.char_code >> 6) & 0x3f));
1112 handle_string_escape(&t, (uint8_t)(0x80 | ((t.char_code >> 6) & 0x3f)));
11131113 // 00000000 00000000 00000000 00xxxxxx
1114 handle_string_escape(&t, 0x80 | (t.char_code & 0x3f));
1114 handle_string_escape(&t, (uint8_t)(0x80 | (t.char_code & 0x3f)));
11151115 } else {
11161116 tokenize_error(&t, "unicode value out of range: %x", t.char_code);
11171117 }
11181118 } else {
1119 if (t.cur_tok->id == TokenIdCharLiteral && t.char_code >= sizeof(uint8_t)) {
1119 if (t.cur_tok->id == TokenIdCharLiteral && t.char_code > UINT8_MAX) {
11201120 tokenize_error(&t, "value too large for character literal: '%x'",
11211121 t.char_code);
11221122 }
1123 handle_string_escape(&t, t.char_code);
1123 handle_string_escape(&t, (uint8_t)t.char_code);
11241124 }
11251125 }
11261126 }
......@@ -1396,8 +1396,8 @@ void tokenize(Buf *buf, Tokenization *out) {
13961396 if (t.state != TokenizeStateError) {
13971397 if (t.tokens->length > 0) {
13981398 Token *last_token = &t.tokens->last();
1399 t.line = last_token->start_line;
1400 t.column = last_token->start_column;
1399 t.line = (int)last_token->start_line;
1400 t.column = (int)last_token->start_column;
14011401 t.pos = last_token->start_pos;
14021402 } else {
14031403 t.pos = 0;
src/util.cpp+1-1
......@@ -36,7 +36,7 @@ bool uint64_eq(uint64_t a, uint64_t b) {
3636}
3737
3838uint32_t ptr_hash(const void *ptr) {
39 return ((uintptr_t)ptr) % UINT32_MAX;
39 return (uint32_t)(((uintptr_t)ptr) % UINT32_MAX);
4040}
4141
4242bool ptr_eq(const void *a, const void *b) {