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 {...@@ -277,7 +277,7 @@ struct TldVar {
277277
278 VariableTableEntry *var;278 VariableTableEntry *var;
279 AstNode *set_global_align_node;279 AstNode *set_global_align_node;
280 uint64_t alignment;280 uint32_t alignment;
281 AstNode *set_global_section_node;281 AstNode *set_global_section_node;
282 Buf *section_name;282 Buf *section_name;
283 AstNode *set_global_linkage_node;283 AstNode *set_global_linkage_node;
...@@ -888,7 +888,7 @@ struct TypeTableEntryPointer {...@@ -888,7 +888,7 @@ struct TypeTableEntryPointer {
888};888};
889889
890struct TypeTableEntryInt {890struct TypeTableEntryInt {
891 size_t bit_count;891 uint32_t bit_count;
892 bool is_signed;892 bool is_signed;
893};893};
894894
...@@ -1146,7 +1146,7 @@ struct FnTableEntry {...@@ -1146,7 +1146,7 @@ struct FnTableEntry {
1146 ZigList<VariableTableEntry *> variable_list;1146 ZigList<VariableTableEntry *> variable_list;
11471147
1148 AstNode *set_global_align_node;1148 AstNode *set_global_align_node;
1149 uint64_t alignment;1149 uint32_t alignment;
1150 AstNode *set_global_section_node;1150 AstNode *set_global_section_node;
1151 Buf *section_name;1151 Buf *section_name;
1152 AstNode *set_global_linkage_node;1152 AstNode *set_global_linkage_node;
...@@ -1251,7 +1251,7 @@ struct TypeId {...@@ -1251,7 +1251,7 @@ struct TypeId {
1251 } array;1251 } array;
1252 struct {1252 struct {
1253 bool is_signed;1253 bool is_signed;
1254 uint8_t bit_count;1254 uint32_t bit_count;
1255 } integer;1255 } integer;
1256 } data;1256 } data;
1257};1257};
src/analyze.cpp+69-65
...@@ -163,7 +163,7 @@ static TypeTableEntry *new_container_type_entry(TypeTableEntryId id, AstNode *so...@@ -163,7 +163,7 @@ static TypeTableEntry *new_container_type_entry(TypeTableEntryId id, AstNode *so
163163
164164
165// TODO no reason to limit to 8/16/32/64165// 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) {
167 if (x <= UINT8_MAX) {167 if (x <= UINT8_MAX) {
168 return 8;168 return 8;
169 } else if (x <= UINT16_MAX) {169 } else if (x <= UINT16_MAX) {
...@@ -578,13 +578,14 @@ TypeTableEntry *get_array_type(CodeGen *g, TypeTableEntry *child_type, uint64_t...@@ -578,13 +578,14 @@ TypeTableEntry *get_array_type(CodeGen *g, TypeTableEntry *child_type, uint64_t
578 buf_appendf(&entry->name, "[%" PRIu64 "]%s", array_size, buf_ptr(&child_type->name));578 buf_appendf(&entry->name, "[%" PRIu64 "]%s", array_size, buf_ptr(&child_type->name));
579579
580 if (!entry->zero_bits) {580 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
583 uint64_t debug_size_in_bits = 8*LLVMStoreSizeOfType(g->target_data_ref, entry->type_ref);584 uint64_t debug_size_in_bits = 8*LLVMStoreSizeOfType(g->target_data_ref, entry->type_ref);
584 uint64_t debug_align_in_bits = 8*LLVMABISizeOfType(g->target_data_ref, entry->type_ref);585 uint64_t debug_align_in_bits = 8*LLVMABISizeOfType(g->target_data_ref, entry->type_ref);
585586
586 entry->di_type = ZigLLVMCreateDebugArrayType(g->dbuilder, debug_size_in_bits,587 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);
588 }589 }
589 entry->data.array.child_type = child_type;590 entry->data.array.child_type = child_type;
590 entry->data.array.len = array_size;591 entry->data.array.len = array_size;
...@@ -911,9 +912,9 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {...@@ -911,9 +912,9 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) {
911 fn_type->data.fn.gen_param_count = gen_param_index;912 fn_type->data.fn.gen_param_count = gen_param_index;
912913
913 fn_type->data.fn.raw_type_ref = LLVMFunctionType(gen_return_type->type_ref,914 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);
915 fn_type->type_ref = LLVMPointerType(fn_type->data.fn.raw_type_ref, 0);916 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);
917 }918 }
918919
919 g->fn_type_table.put(&fn_type->data.fn.fn_type_id, fn_type);920 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...@@ -954,13 +955,13 @@ TypeTableEntry *get_partial_container_type(CodeGen *g, Scope *scope, ContainerKi
954 break;955 break;
955 }956 }
956957
957 unsigned line = decl_node ? decl_node->line : 0;958 size_t line = decl_node ? decl_node->line : 0;
958959
959 ImportTableEntry *import = get_scope_import(scope);960 ImportTableEntry *import = get_scope_import(scope);
960 entry->type_ref = LLVMStructCreateNamed(LLVMGetGlobalContext(), name);961 entry->type_ref = LLVMStructCreateNamed(LLVMGetGlobalContext(), name);
961 entry->di_type = ZigLLVMCreateReplaceableCompositeType(g->dbuilder,962 entry->di_type = ZigLLVMCreateReplaceableCompositeType(g->dbuilder,
962 ZigLLVMTag_DW_structure_type(), name,963 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
965 buf_init_from_str(&entry->name, name);966 buf_init_from_str(&entry->name, name);
966967
...@@ -1264,7 +1265,7 @@ static void resolve_enum_type(CodeGen *g, TypeTableEntry *enum_type) {...@@ -1264,7 +1265,7 @@ static void resolve_enum_type(CodeGen *g, TypeTableEntry *enum_type) {
12641265
1265 union_inner_di_types[type_enum_field->gen_index] = ZigLLVMCreateDebugMemberType(g->dbuilder,1266 union_inner_di_types[type_enum_field->gen_index] = ZigLLVMCreateDebugMemberType(g->dbuilder,
1266 ZigLLVMTypeToScope(enum_type->di_type), buf_ptr(type_enum_field->name),1267 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),
1268 debug_size_in_bits,1269 debug_size_in_bits,
1269 debug_align_in_bits,1270 debug_align_in_bits,
1270 0,1271 0,
...@@ -1307,13 +1308,15 @@ static void resolve_enum_type(CodeGen *g, TypeTableEntry *enum_type) {...@@ -1307,13 +1308,15 @@ static void resolve_enum_type(CodeGen *g, TypeTableEntry *enum_type) {
1307 uint64_t tag_debug_size_in_bits = 8*LLVMStoreSizeOfType(g->target_data_ref, tag_type_entry->type_ref);1308 uint64_t tag_debug_size_in_bits = 8*LLVMStoreSizeOfType(g->target_data_ref, tag_type_entry->type_ref);
1308 uint64_t tag_debug_align_in_bits = 8*LLVMABISizeOfType(g->target_data_ref, tag_type_entry->type_ref);1309 uint64_t tag_debug_align_in_bits = 8*LLVMABISizeOfType(g->target_data_ref, tag_type_entry->type_ref);
1309 ZigLLVMDIType *tag_di_type = ZigLLVMCreateDebugEnumerationType(g->dbuilder,1310 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),
1311 tag_debug_size_in_bits, tag_debug_align_in_bits, di_enumerators, field_count,1313 tag_debug_size_in_bits, tag_debug_align_in_bits, di_enumerators, field_count,
1312 tag_type_entry->di_type, "");1314 tag_type_entry->di_type, "");
13131315
1314 // create debug type for union1316 // create debug type for union
1315 ZigLLVMDIType *union_di_type = ZigLLVMCreateDebugUnionType(g->dbuilder,1317 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),
1317 biggest_union_member_size_in_bits, biggest_align_in_bits, 0, union_inner_di_types,1320 biggest_union_member_size_in_bits, biggest_align_in_bits, 0, union_inner_di_types,
1318 gen_field_count, 0, "");1321 gen_field_count, 0, "");
13191322
...@@ -1321,7 +1324,7 @@ static void resolve_enum_type(CodeGen *g, TypeTableEntry *enum_type) {...@@ -1321,7 +1324,7 @@ static void resolve_enum_type(CodeGen *g, TypeTableEntry *enum_type) {
1321 uint64_t tag_offset_in_bits = 8*LLVMOffsetOfElement(g->target_data_ref, enum_type->type_ref, 0);1324 uint64_t tag_offset_in_bits = 8*LLVMOffsetOfElement(g->target_data_ref, enum_type->type_ref, 0);
1322 ZigLLVMDIType *tag_member_di_type = ZigLLVMCreateDebugMemberType(g->dbuilder,1325 ZigLLVMDIType *tag_member_di_type = ZigLLVMCreateDebugMemberType(g->dbuilder,
1323 ZigLLVMTypeToScope(enum_type->di_type), "tag_field",1326 ZigLLVMTypeToScope(enum_type->di_type), "tag_field",
1324 import->di_file, decl_node->line + 1,1327 import->di_file, (unsigned)(decl_node->line + 1),
1325 tag_debug_size_in_bits,1328 tag_debug_size_in_bits,
1326 tag_debug_align_in_bits,1329 tag_debug_align_in_bits,
1327 tag_offset_in_bits,1330 tag_offset_in_bits,
...@@ -1330,7 +1333,7 @@ static void resolve_enum_type(CodeGen *g, TypeTableEntry *enum_type) {...@@ -1330,7 +1333,7 @@ static void resolve_enum_type(CodeGen *g, TypeTableEntry *enum_type) {
1330 uint64_t union_offset_in_bits = 8*LLVMOffsetOfElement(g->target_data_ref, enum_type->type_ref, 1);1333 uint64_t union_offset_in_bits = 8*LLVMOffsetOfElement(g->target_data_ref, enum_type->type_ref, 1);
1331 ZigLLVMDIType *union_member_di_type = ZigLLVMCreateDebugMemberType(g->dbuilder,1334 ZigLLVMDIType *union_member_di_type = ZigLLVMCreateDebugMemberType(g->dbuilder,
1332 ZigLLVMTypeToScope(enum_type->di_type), "union_field",1335 ZigLLVMTypeToScope(enum_type->di_type), "union_field",
1333 import->di_file, decl_node->line + 1,1336 import->di_file, (unsigned)(decl_node->line + 1),
1334 biggest_union_member_size_in_bits,1337 biggest_union_member_size_in_bits,
1335 biggest_align_in_bits,1338 biggest_align_in_bits,
1336 union_offset_in_bits,1339 union_offset_in_bits,
...@@ -1348,7 +1351,7 @@ static void resolve_enum_type(CodeGen *g, TypeTableEntry *enum_type) {...@@ -1348,7 +1351,7 @@ static void resolve_enum_type(CodeGen *g, TypeTableEntry *enum_type) {
1348 ZigLLVMDIType *replacement_di_type = ZigLLVMCreateDebugStructType(g->dbuilder,1351 ZigLLVMDIType *replacement_di_type = ZigLLVMCreateDebugStructType(g->dbuilder,
1349 ZigLLVMFileToScope(import->di_file),1352 ZigLLVMFileToScope(import->di_file),
1350 buf_ptr(&enum_type->name),1353 buf_ptr(&enum_type->name),
1351 import->di_file, decl_node->line + 1,1354 import->di_file, (unsigned)(decl_node->line + 1),
1352 debug_size_in_bits,1355 debug_size_in_bits,
1353 debug_align_in_bits,1356 debug_align_in_bits,
1354 0, nullptr, di_root_members, 2, 0, nullptr, "");1357 0, nullptr, di_root_members, 2, 0, nullptr, "");
...@@ -1364,7 +1367,7 @@ static void resolve_enum_type(CodeGen *g, TypeTableEntry *enum_type) {...@@ -1364,7 +1367,7 @@ static void resolve_enum_type(CodeGen *g, TypeTableEntry *enum_type) {
1364 uint64_t tag_debug_align_in_bits = 8*LLVMABISizeOfType(g->target_data_ref, tag_type_entry->type_ref);1367 uint64_t tag_debug_align_in_bits = 8*LLVMABISizeOfType(g->target_data_ref, tag_type_entry->type_ref);
1365 ZigLLVMDIType *tag_di_type = ZigLLVMCreateDebugEnumerationType(g->dbuilder,1368 ZigLLVMDIType *tag_di_type = ZigLLVMCreateDebugEnumerationType(g->dbuilder,
1366 ZigLLVMFileToScope(import->di_file), buf_ptr(&enum_type->name),1369 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),
1368 tag_debug_size_in_bits,1371 tag_debug_size_in_bits,
1369 tag_debug_align_in_bits,1372 tag_debug_align_in_bits,
1370 di_enumerators, field_count,1373 di_enumerators, field_count,
...@@ -1499,7 +1502,7 @@ static void resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) {...@@ -1499,7 +1502,7 @@ static void resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) {
1499 type_struct_field->unaligned_bit_count = field_size_in_bits;1502 type_struct_field->unaligned_bit_count = field_size_in_bits;
15001503
1501 size_t full_bit_count = next_packed_bits_offset - first_packed_bits_offset_misalign;1504 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));
1503 if (8 * LLVMStoreSizeOfType(g->target_data_ref, int_type_ref) == full_bit_count) {1506 if (8 * LLVMStoreSizeOfType(g->target_data_ref, int_type_ref) == full_bit_count) {
1504 // next field recovers store alignment1507 // next field recovers store alignment
1505 element_types[gen_field_index] = int_type_ref;1508 element_types[gen_field_index] = int_type_ref;
...@@ -1529,9 +1532,9 @@ static void resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) {...@@ -1529,9 +1532,9 @@ static void resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) {
1529 }1532 }
1530 if (first_packed_bits_offset_misalign != SIZE_MAX) {1533 if (first_packed_bits_offset_misalign != SIZE_MAX) {
1531 size_t full_bit_count = packed_bits_offset - first_packed_bits_offset_misalign;1534 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);
1533 size_t store_bit_count = 8 * LLVMStoreSizeOfType(g->target_data_ref, int_type_ref);1536 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);
1535 gen_field_index += 1;1538 gen_field_index += 1;
1536 }1539 }
15371540
...@@ -1552,9 +1555,9 @@ static void resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) {...@@ -1552,9 +1555,9 @@ static void resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) {
15521555
1553 // the count may have been adjusting from packing bit fields1556 // the count may have been adjusting from packing bit fields
1554 gen_field_count = gen_field_index;1557 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);
1558 assert(LLVMStoreSizeOfType(g->target_data_ref, struct_type->type_ref) > 0);1561 assert(LLVMStoreSizeOfType(g->target_data_ref, struct_type->type_ref) > 0);
15591562
1560 ZigLLVMDIType **di_element_types = allocate<ZigLLVMDIType*>(debug_field_count);1563 ZigLLVMDIType **di_element_types = allocate<ZigLLVMDIType*>(debug_field_count);
...@@ -1593,15 +1596,16 @@ static void resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) {...@@ -1593,15 +1596,16 @@ static void resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) {
1593 debug_size_in_bits = type_struct_field->packed_bits_size;1596 debug_size_in_bits = type_struct_field->packed_bits_size;
1594 debug_align_in_bits = 1;1597 debug_align_in_bits = 1;
1595 debug_offset_in_bits = 8*LLVMOffsetOfElement(g->target_data_ref, struct_type->type_ref,1598 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;
1597 } else {1600 } else {
1598 debug_size_in_bits = 8*LLVMStoreSizeOfType(g->target_data_ref, field_type->type_ref);1601 debug_size_in_bits = 8*LLVMStoreSizeOfType(g->target_data_ref, field_type->type_ref);
1599 debug_align_in_bits = 8*LLVMABISizeOfType(g->target_data_ref, field_type->type_ref);1602 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);
1601 }1605 }
1602 di_element_types[debug_field_index] = ZigLLVMCreateDebugMemberType(g->dbuilder,1606 di_element_types[debug_field_index] = ZigLLVMCreateDebugMemberType(g->dbuilder,
1603 ZigLLVMTypeToScope(struct_type->di_type), buf_ptr(type_struct_field->name),1607 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),
1605 debug_size_in_bits,1609 debug_size_in_bits,
1606 debug_align_in_bits,1610 debug_align_in_bits,
1607 debug_offset_in_bits,1611 debug_offset_in_bits,
...@@ -1616,10 +1620,10 @@ static void resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) {...@@ -1616,10 +1620,10 @@ static void resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) {
1616 ZigLLVMDIType *replacement_di_type = ZigLLVMCreateDebugStructType(g->dbuilder,1620 ZigLLVMDIType *replacement_di_type = ZigLLVMCreateDebugStructType(g->dbuilder,
1617 ZigLLVMFileToScope(import->di_file),1621 ZigLLVMFileToScope(import->di_file),
1618 buf_ptr(&struct_type->name),1622 buf_ptr(&struct_type->name),
1619 import->di_file, decl_node->line + 1,1623 import->di_file, (unsigned)(decl_node->line + 1),
1620 debug_size_in_bits,1624 debug_size_in_bits,
1621 debug_align_in_bits,1625 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
1624 ZigLLVMReplaceTemporary(g->dbuilder, struct_type->di_type, replacement_di_type);1628 ZigLLVMReplaceTemporary(g->dbuilder, struct_type->di_type, replacement_di_type);
1625 struct_type->di_type = replacement_di_type;1629 struct_type->di_type = replacement_di_type;
...@@ -1647,7 +1651,7 @@ static void resolve_enum_zero_bits(CodeGen *g, TypeTableEntry *enum_type) {...@@ -1647,7 +1651,7 @@ static void resolve_enum_zero_bits(CodeGen *g, TypeTableEntry *enum_type) {
1647 assert(enum_type->di_type);1651 assert(enum_type->di_type);
16481652
1649 assert(!enum_type->data.enumeration.fields);1653 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;
1651 enum_type->data.enumeration.src_field_count = field_count;1655 enum_type->data.enumeration.src_field_count = field_count;
1652 enum_type->data.enumeration.fields = allocate<TypeEnumField>(field_count);1656 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) {...@@ -1700,7 +1704,7 @@ static void resolve_struct_zero_bits(CodeGen *g, TypeTableEntry *struct_type) {
17001704
1701 assert(!struct_type->data.structure.fields);1705 assert(!struct_type->data.structure.fields);
1702 size_t field_count = decl_node->data.container_decl.fields.length;1706 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;
1704 struct_type->data.structure.fields = allocate<TypeStructField>(field_count);1708 struct_type->data.structure.fields = allocate<TypeStructField>(field_count);
17051709
1706 Scope *scope = &struct_type->data.structure.decls_scope->base;1710 Scope *scope = &struct_type->data.structure.decls_scope->base;
...@@ -1729,7 +1733,7 @@ static void resolve_struct_zero_bits(CodeGen *g, TypeTableEntry *struct_type) {...@@ -1729,7 +1733,7 @@ static void resolve_struct_zero_bits(CodeGen *g, TypeTableEntry *struct_type) {
1729 }1733 }
17301734
1731 struct_type->data.structure.zero_bits_loop_flag = false;1735 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;
1733 struct_type->zero_bits = (gen_field_index == 0);1737 struct_type->zero_bits = (gen_field_index == 0);
1734 struct_type->data.structure.zero_bits_known = true;1738 struct_type->data.structure.zero_bits_known = true;
1735}1739}
...@@ -1985,7 +1989,7 @@ static void preview_error_value_decl(CodeGen *g, AstNode *node) {...@@ -1985,7 +1989,7 @@ static void preview_error_value_decl(CodeGen *g, AstNode *node) {
1985 } else {1989 } else {
1986 size_t error_value_count = g->error_decls.length;1990 size_t error_value_count = g->error_decls.length;
1987 assert((uint32_t)error_value_count < (((uint32_t)1) << (uint32_t)g->err_tag_type->data.integral.bit_count));1991 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;
1989 g->error_decls.append(node);1993 g->error_decls.append(node);
1990 g->error_table.put(&err->name, err);1994 g->error_table.put(&err->name, err);
1991 }1995 }
...@@ -2999,7 +3003,7 @@ bool is_node_void_expr(AstNode *node) {...@@ -2999,7 +3003,7 @@ bool is_node_void_expr(AstNode *node) {
2999 return false;3003 return false;
3000}3004}
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) {
3003 size_t index;3007 size_t index;
3004 if (size_in_bits == 8) {3008 if (size_in_bits == 8) {
3005 index = 0;3009 index = 0;
...@@ -3015,7 +3019,7 @@ TypeTableEntry **get_int_type_ptr(CodeGen *g, bool is_signed, uint8_t size_in_bi...@@ -3015,7 +3019,7 @@ TypeTableEntry **get_int_type_ptr(CodeGen *g, bool is_signed, uint8_t size_in_bi
3015 return &g->builtin_types.entry_int[is_signed ? 0 : 1][index];3019 return &g->builtin_types.entry_int[is_signed ? 0 : 1][index];
3016}3020}
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) {
3019 TypeTableEntry **common_entry = get_int_type_ptr(g, is_signed, size_in_bits);3023 TypeTableEntry **common_entry = get_int_type_ptr(g, is_signed, size_in_bits);
3020 if (common_entry)3024 if (common_entry)
3021 return *common_entry;3025 return *common_entry;
...@@ -3104,11 +3108,11 @@ void find_libc_lib_path(CodeGen *g) {...@@ -3104,11 +3108,11 @@ void find_libc_lib_path(CodeGen *g) {
3104}3108}
31053109
3106static uint32_t hash_ptr(void *ptr) {3110static uint32_t hash_ptr(void *ptr) {
3107 return ((uintptr_t)ptr) % UINT32_MAX;3111 return (uint32_t)(((uintptr_t)ptr) % UINT32_MAX);
3108}3112}
31093113
3110static uint32_t hash_size(size_t x) {3114static uint32_t hash_size(size_t x) {
3111 return x % UINT32_MAX;3115 return (uint32_t)(x % UINT32_MAX);
3112}3116}
31133117
3114uint32_t fn_table_entry_hash(FnTableEntry* value) {3118uint32_t fn_table_entry_hash(FnTableEntry* value) {
...@@ -3121,14 +3125,14 @@ bool fn_table_entry_eql(FnTableEntry *a, FnTableEntry *b) {...@@ -3121,14 +3125,14 @@ bool fn_table_entry_eql(FnTableEntry *a, FnTableEntry *b) {
31213125
3122uint32_t fn_type_id_hash(FnTypeId *id) {3126uint32_t fn_type_id_hash(FnTypeId *id) {
3123 uint32_t result = 0;3127 uint32_t result = 0;
3124 result += id->is_extern ? 3349388391 : 0;3128 result += id->is_extern ? (uint32_t)3349388391 : 0;
3125 result += id->is_naked ? 608688877 : 0;3129 result += id->is_naked ? (uint32_t)608688877 : 0;
3126 result += id->is_cold ? 3605523458 : 0;3130 result += id->is_cold ? (uint32_t)3605523458 : 0;
3127 result += id->is_var_args ? 1931444534 : 0;3131 result += id->is_var_args ? (uint32_t)1931444534 : 0;
3128 result += hash_ptr(id->return_type);3132 result += hash_ptr(id->return_type);
3129 for (size_t i = 0; i < id->param_count; i += 1) {3133 for (size_t i = 0; i < id->param_count; i += 1) {
3130 FnTypeParamInfo *info = &id->param_info[i];3134 FnTypeParamInfo *info = &id->param_info[i];
3131 result += info->is_noalias ? 892356923 : 0;3135 result += info->is_noalias ? (uint32_t)892356923 : 0;
3132 result += hash_ptr(info->type);3136 result += hash_ptr(info->type);
3133 }3137 }
3134 return result;3138 return result;
...@@ -3161,55 +3165,55 @@ static uint32_t hash_const_val(ConstExprValue *const_val) {...@@ -3161,55 +3165,55 @@ static uint32_t hash_const_val(ConstExprValue *const_val) {
3161 assert(const_val->special == ConstValSpecialStatic);3165 assert(const_val->special == ConstValSpecialStatic);
3162 switch (const_val->type->id) {3166 switch (const_val->type->id) {
3163 case TypeTableEntryIdBool:3167 case TypeTableEntryIdBool:
3164 return const_val->data.x_bool ? 127863866 : 215080464;3168 return const_val->data.x_bool ? (uint32_t)127863866 : (uint32_t)215080464;
3165 case TypeTableEntryIdMetaType:3169 case TypeTableEntryIdMetaType:
3166 return hash_ptr(const_val->data.x_type);3170 return hash_ptr(const_val->data.x_type);
3167 case TypeTableEntryIdVoid:3171 case TypeTableEntryIdVoid:
3168 return 4149439618;3172 return (uint32_t)4149439618;
3169 case TypeTableEntryIdInt:3173 case TypeTableEntryIdInt:
3170 case TypeTableEntryIdNumLitInt:3174 case TypeTableEntryIdNumLitInt:
3171 case TypeTableEntryIdEnumTag:3175 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;
3173 case TypeTableEntryIdFloat:3177 case TypeTableEntryIdFloat:
3174 case TypeTableEntryIdNumLitFloat:3178 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);
3176 case TypeTableEntryIdArgTuple:3180 case TypeTableEntryIdArgTuple:
3177 return const_val->data.x_arg_tuple.start_index * 281907309 +3181 return (uint32_t)const_val->data.x_arg_tuple.start_index * (uint32_t)281907309 +
3178 const_val->data.x_arg_tuple.end_index * 2290442768;3182 (uint32_t)const_val->data.x_arg_tuple.end_index * (uint32_t)2290442768;
3179 case TypeTableEntryIdPointer:3183 case TypeTableEntryIdPointer:
3180 {3184 {
3181 uint32_t hash_val = 0;3185 uint32_t hash_val = 0;
3182 switch (const_val->data.x_ptr.mut) {3186 switch (const_val->data.x_ptr.mut) {
3183 case ConstPtrMutRuntimeVar:3187 case ConstPtrMutRuntimeVar:
3184 hash_val += 3500721036;3188 hash_val += (uint32_t)3500721036;
3185 break;3189 break;
3186 case ConstPtrMutComptimeConst:3190 case ConstPtrMutComptimeConst:
3187 hash_val += 4214318515;3191 hash_val += (uint32_t)4214318515;
3188 break;3192 break;
3189 case ConstPtrMutComptimeVar:3193 case ConstPtrMutComptimeVar:
3190 hash_val += 1103195694;3194 hash_val += (uint32_t)1103195694;
3191 break;3195 break;
3192 }3196 }
3193 switch (const_val->data.x_ptr.special) {3197 switch (const_val->data.x_ptr.special) {
3194 case ConstPtrSpecialInvalid:3198 case ConstPtrSpecialInvalid:
3195 zig_unreachable();3199 zig_unreachable();
3196 case ConstPtrSpecialRef:3200 case ConstPtrSpecialRef:
3197 hash_val += 2478261866;3201 hash_val += (uint32_t)2478261866;
3198 hash_val += hash_ptr(const_val->data.x_ptr.data.ref.pointee);3202 hash_val += hash_ptr(const_val->data.x_ptr.data.ref.pointee);
3199 return hash_val;3203 return hash_val;
3200 case ConstPtrSpecialBaseArray:3204 case ConstPtrSpecialBaseArray:
3201 hash_val += 1764906839;3205 hash_val += (uint32_t)1764906839;
3202 hash_val += hash_ptr(const_val->data.x_ptr.data.base_array.array_val);3206 hash_val += hash_ptr(const_val->data.x_ptr.data.base_array.array_val);
3203 hash_val += hash_size(const_val->data.x_ptr.data.base_array.elem_index);3207 hash_val += hash_size(const_val->data.x_ptr.data.base_array.elem_index);
3204 hash_val += const_val->data.x_ptr.data.base_array.is_cstr ? 1297263887 : 200363492;3208 hash_val += const_val->data.x_ptr.data.base_array.is_cstr ? 1297263887 : 200363492;
3205 return hash_val;3209 return hash_val;
3206 case ConstPtrSpecialBaseStruct:3210 case ConstPtrSpecialBaseStruct:
3207 hash_val += 3518317043;3211 hash_val += (uint32_t)3518317043;
3208 hash_val += hash_ptr(const_val->data.x_ptr.data.base_struct.struct_val);3212 hash_val += hash_ptr(const_val->data.x_ptr.data.base_struct.struct_val);
3209 hash_val += hash_size(const_val->data.x_ptr.data.base_struct.field_index);3213 hash_val += hash_size(const_val->data.x_ptr.data.base_struct.field_index);
3210 return hash_val;3214 return hash_val;
3211 case ConstPtrSpecialHardCodedAddr:3215 case ConstPtrSpecialHardCodedAddr:
3212 hash_val += 4048518294;3216 hash_val += (uint32_t)4048518294;
3213 hash_val += hash_size(const_val->data.x_ptr.data.hard_coded_addr.addr);3217 hash_val += hash_size(const_val->data.x_ptr.data.hard_coded_addr.addr);
3214 return hash_val;3218 return hash_val;
3215 case ConstPtrSpecialDiscard:3219 case ConstPtrSpecialDiscard:
...@@ -3954,7 +3958,7 @@ void render_const_value(Buf *buf, ConstExprValue *const_val) {...@@ -3954,7 +3958,7 @@ void render_const_value(Buf *buf, ConstExprValue *const_val) {
3954 ConstExprValue *child_value = &const_val->data.x_array.elements[i];3958 ConstExprValue *child_value = &const_val->data.x_array.elements[i];
3955 uint64_t big_c = child_value->data.x_bignum.data.x_uint;3959 uint64_t big_c = child_value->data.x_bignum.data.x_uint;
3956 assert(big_c <= UINT8_MAX);3960 assert(big_c <= UINT8_MAX);
3957 uint8_t c = big_c;3961 uint8_t c = (uint8_t)big_c;
3958 if (c == '"') {3962 if (c == '"') {
3959 buf_append_str(buf, "\\\"");3963 buf_append_str(buf, "\\\"");
3960 } else {3964 } else {
...@@ -4051,14 +4055,14 @@ void render_const_value(Buf *buf, ConstExprValue *const_val) {...@@ -4051,14 +4055,14 @@ void render_const_value(Buf *buf, ConstExprValue *const_val) {
4051 zig_unreachable();4055 zig_unreachable();
4052}4056}
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) {
4055 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdInt);4059 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdInt);
4056 entry->is_copyable = true;4060 entry->is_copyable = true;
4057 entry->type_ref = LLVMIntType(size_in_bits);4061 entry->type_ref = LLVMIntType(size_in_bits);
40584062
4059 const char u_or_i = is_signed ? 'i' : 'u';4063 const char u_or_i = is_signed ? 'i' : 'u';
4060 buf_resize(&entry->name, 0);4064 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
4063 unsigned dwarf_tag;4067 unsigned dwarf_tag;
4064 if (is_signed) {4068 if (is_signed) {
...@@ -4111,16 +4115,16 @@ uint32_t type_id_hash(TypeId x) {...@@ -4111,16 +4115,16 @@ uint32_t type_id_hash(TypeId x) {
4111 zig_unreachable();4115 zig_unreachable();
4112 case TypeTableEntryIdPointer:4116 case TypeTableEntryIdPointer:
4113 return hash_ptr(x.data.pointer.child_type) +4117 return hash_ptr(x.data.pointer.child_type) +
4114 (x.data.pointer.is_const ? 2749109194 : 4047371087) +4118 (x.data.pointer.is_const ? (uint32_t)2749109194 : (uint32_t)4047371087) +
4115 (x.data.pointer.is_volatile ? 536730450 : 1685612214) +4119 (x.data.pointer.is_volatile ? (uint32_t)536730450 : (uint32_t)1685612214) +
4116 (((uint32_t)x.data.pointer.bit_offset) * 2639019452) +4120 (((uint32_t)x.data.pointer.bit_offset) * (uint32_t)2639019452) +
4117 (((uint32_t)x.data.pointer.unaligned_bit_count) * 529908881);4121 (((uint32_t)x.data.pointer.unaligned_bit_count) * (uint32_t)529908881);
4118 case TypeTableEntryIdArray:4122 case TypeTableEntryIdArray:
4119 return hash_ptr(x.data.array.child_type) +4123 return hash_ptr(x.data.array.child_type) +
4120 (x.data.array.size * 2122979968);4124 ((uint32_t)x.data.array.size * (uint32_t)2122979968);
4121 case TypeTableEntryIdInt:4125 case TypeTableEntryIdInt:
4122 return (x.data.integer.is_signed ? 2652528194 : 163929201) +4126 return (x.data.integer.is_signed ? (uint32_t)2652528194 : (uint32_t)163929201) +
4123 (((uint32_t)x.data.integer.bit_count) * 2998081557);4127 (((uint32_t)x.data.integer.bit_count) * (uint32_t)2998081557);
4124 }4128 }
4125 zig_unreachable();4129 zig_unreachable();
4126}4130}
...@@ -4173,13 +4177,13 @@ bool type_id_eql(TypeId a, TypeId b) {...@@ -4173,13 +4177,13 @@ bool type_id_eql(TypeId a, TypeId b) {
4173uint32_t zig_llvm_fn_key_hash(ZigLLVMFnKey x) {4177uint32_t zig_llvm_fn_key_hash(ZigLLVMFnKey x) {
4174 switch (x.id) {4178 switch (x.id) {
4175 case ZigLLVMFnIdCtz:4179 case ZigLLVMFnIdCtz:
4176 return x.data.ctz.bit_count * 810453934;4180 return (uint32_t)(x.data.ctz.bit_count) * (uint32_t)810453934;
4177 case ZigLLVMFnIdClz:4181 case ZigLLVMFnIdClz:
4178 return x.data.clz.bit_count * 2428952817;4182 return (uint32_t)(x.data.clz.bit_count) * (uint32_t)2428952817;
4179 case ZigLLVMFnIdOverflowArithmetic:4183 case ZigLLVMFnIdOverflowArithmetic:
4180 return (x.data.overflow_arithmetic.bit_count * 87135777) +4184 return ((uint32_t)(x.data.overflow_arithmetic.bit_count) * 87135777) +
4181 (x.data.overflow_arithmetic.add_sub_mul * 31640542) +4185 ((uint32_t)(x.data.overflow_arithmetic.add_sub_mul) * 31640542) +
4182 (x.data.overflow_arithmetic.is_signed ? 1062315172 : 314955820);4186 ((uint32_t)(x.data.overflow_arithmetic.is_signed) ? 1062315172 : 314955820);
4183 }4187 }
4184 zig_unreachable();4188 zig_unreachable();
4185}4189}
src/analyze.hpp+3-3
...@@ -20,8 +20,8 @@ TypeTableEntry *get_pointer_to_type_extra(CodeGen *g, TypeTableEntry *child_type...@@ -20,8 +20,8 @@ TypeTableEntry *get_pointer_to_type_extra(CodeGen *g, TypeTableEntry *child_type
20bool is_node_void_expr(AstNode *node);20bool is_node_void_expr(AstNode *node);
21uint64_t type_size(CodeGen *g, TypeTableEntry *type_entry);21uint64_t type_size(CodeGen *g, TypeTableEntry *type_entry);
22uint64_t type_size_bits(CodeGen *g, TypeTableEntry *type_entry);22uint64_t type_size_bits(CodeGen *g, TypeTableEntry *type_entry);
23TypeTableEntry **get_int_type_ptr(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, uint8_t size_in_bits);24TypeTableEntry *get_int_type(CodeGen *g, bool is_signed, uint32_t size_in_bits);
25TypeTableEntry **get_c_int_type_ptr(CodeGen *g, CIntType c_int_type);25TypeTableEntry **get_c_int_type_ptr(CodeGen *g, CIntType c_int_type);
26TypeTableEntry *get_c_int_type(CodeGen *g, CIntType c_int_type);26TypeTableEntry *get_c_int_type(CodeGen *g, CIntType c_int_type);
27TypeTableEntry *get_typedecl_type(CodeGen *g, const char *name, TypeTableEntry *child_type);27TypeTableEntry *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_...@@ -146,7 +146,7 @@ ConstExprValue *create_const_arg_tuple(CodeGen *g, size_t arg_index_start, size_
146146
147void init_const_undefined(CodeGen *g, ConstExprValue *const_val);147void 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);
150ConstParent *get_const_val_parent(ConstExprValue *value);150ConstParent *get_const_val_parent(ConstExprValue *value);
151FnTableEntry *get_extern_panic_fn(CodeGen *g);151FnTableEntry *get_extern_panic_fn(CodeGen *g);
152TypeTableEntry *create_enum_tag_type(CodeGen *g, TypeTableEntry *enum_type, TypeTableEntry *int_type);152TypeTableEntry *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) {...@@ -409,8 +409,8 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) {
409 fprintf(ar->f, "%s%s%sfn ", pub_str, inline_str, extern_str);409 fprintf(ar->f, "%s%s%sfn ", pub_str, inline_str, extern_str);
410 print_symbol(ar, node->data.fn_proto.name);410 print_symbol(ar, node->data.fn_proto.name);
411 fprintf(ar->f, "(");411 fprintf(ar->f, "(");
412 int arg_count = node->data.fn_proto.params.length;412 size_t arg_count = node->data.fn_proto.params.length;
413 for (int arg_i = 0; arg_i < arg_count; arg_i += 1) {413 for (size_t arg_i = 0; arg_i < arg_count; arg_i += 1) {
414 AstNode *param_decl = node->data.fn_proto.params.at(arg_i);414 AstNode *param_decl = node->data.fn_proto.params.at(arg_i);
415 assert(param_decl->type == NodeTypeParamDecl);415 assert(param_decl->type == NodeTypeParamDecl);
416 if (buf_len(param_decl->data.param_decl.name) > 0) {416 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) {...@@ -154,7 +154,7 @@ void bignum_cast_to_float(BigNum *dest, BigNum *op) {
154 assert(op->kind == BigNumKindInt);154 assert(op->kind == BigNumKindInt);
155 dest->kind = BigNumKindFloat;155 dest->kind = BigNumKindFloat;
156156
157 dest->data.x_float = op->data.x_uint;157 dest->data.x_float = (double)op->data.x_uint;
158158
159 if (op->is_negative) {159 if (op->is_negative) {
160 dest->data.x_float = -dest->data.x_float;160 dest->data.x_float = -dest->data.x_float;
...@@ -166,10 +166,10 @@ void bignum_cast_to_int(BigNum *dest, BigNum *op) {...@@ -166,10 +166,10 @@ void bignum_cast_to_int(BigNum *dest, BigNum *op) {
166 dest->kind = BigNumKindInt;166 dest->kind = BigNumKindInt;
167167
168 if (op->data.x_float >= 0) {168 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;
170 dest->is_negative = false;170 dest->is_negative = false;
171 } else {171 } else {
172 dest->data.x_uint = -op->data.x_float;172 dest->data.x_uint = (unsigned long long)-op->data.x_float;
173 dest->is_negative = true;173 dest->is_negative = true;
174 }174 }
175}175}
src/buffer.hpp+1-1
...@@ -169,7 +169,7 @@ uint32_t buf_hash(Buf *buf);...@@ -169,7 +169,7 @@ uint32_t buf_hash(Buf *buf);
169169
170static inline void buf_upcase(Buf *buf) {170static inline void buf_upcase(Buf *buf) {
171 for (size_t i = 0; i < buf_len(buf); i += 1) {171 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]);
173 }173 }
174}174}
175175
src/c_tokenizer.cpp+3-3
...@@ -548,7 +548,7 @@ void tokenize_c_macro(CTokenize *ctok, const uint8_t *c) {...@@ -548,7 +548,7 @@ void tokenize_c_macro(CTokenize *ctok, const uint8_t *c) {
548 case '6':548 case '6':
549 case '7':549 case '7':
550 ctok->state = CTokStateStrOctal;550 ctok->state = CTokStateStrOctal;
551 ctok->cur_char = *c - '0';551 ctok->cur_char = (uint8_t)(*c - '0');
552 ctok->octal_index = 1;552 ctok->octal_index = 1;
553 break;553 break;
554 case 'x':554 case 'x':
...@@ -578,12 +578,12 @@ void tokenize_c_macro(CTokenize *ctok, const uint8_t *c) {...@@ -578,12 +578,12 @@ void tokenize_c_macro(CTokenize *ctok, const uint8_t *c) {
578 if (((long)ctok->cur_char) * 8 >= 256) {578 if (((long)ctok->cur_char) * 8 >= 256) {
579 zig_panic("TODO");579 zig_panic("TODO");
580 }580 }
581 ctok->cur_char *= 8;581 ctok->cur_char = (uint8_t)(ctok->cur_char * (uint8_t)8);
582 // TODO @add_with_overflow582 // TODO @add_with_overflow
583 if (((long)ctok->cur_char) + (long)(*c - '0') >= 256) {583 if (((long)ctok->cur_char) + (long)(*c - '0') >= 256) {
584 zig_panic("TODO");584 zig_panic("TODO");
585 }585 }
586 ctok->cur_char += *c - '0';586 ctok->cur_char = (uint8_t)(ctok->cur_char + (uint8_t)(*c - '0'));
587 ctok->octal_index += 1;587 ctok->octal_index += 1;
588 if (ctok->octal_index == 3) {588 if (ctok->octal_index == 3) {
589 if (ctok->cur_tok->id == CTokIdStrLit) {589 if (ctok->cur_tok->id == CTokIdStrLit) {
src/codegen.cpp+79-71
...@@ -267,7 +267,7 @@ static void addLLVMAttrStr(LLVMValueRef val, LLVMAttributeIndex attr_index,...@@ -267,7 +267,7 @@ static void addLLVMAttrStr(LLVMValueRef val, LLVMAttributeIndex attr_index,
267 const char *attr_name, const char *attr_val)267 const char *attr_name, const char *attr_val)
268{268{
269 LLVMAttributeRef llvm_attr = LLVMCreateStringAttribute(LLVMGetGlobalContext(),269 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));
271 LLVMAddAttributeAtIndex(val, attr_index, llvm_attr);271 LLVMAddAttributeAtIndex(val, attr_index, llvm_attr);
272}272}
273273
...@@ -384,7 +384,7 @@ static LLVMValueRef fn_llvm_value(CodeGen *g, FnTableEntry *fn_table_entry) {...@@ -384,7 +384,7 @@ static LLVMValueRef fn_llvm_value(CodeGen *g, FnTableEntry *fn_table_entry) {
384 LLVMSetSection(fn_table_entry->llvm_value, buf_ptr(fn_table_entry->section_name));384 LLVMSetSection(fn_table_entry->llvm_value, buf_ptr(fn_table_entry->section_name));
385 }385 }
386 if (fn_table_entry->alignment) {386 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);
388 }388 }
389389
390 return fn_table_entry->llvm_value;390 return fn_table_entry->llvm_value;
...@@ -405,7 +405,7 @@ static ZigLLVMDIScope *get_di_scope(CodeGen *g, Scope *scope) {...@@ -405,7 +405,7 @@ static ZigLLVMDIScope *get_di_scope(CodeGen *g, Scope *scope) {
405 FnTableEntry *fn_table_entry = fn_scope->fn_entry;405 FnTableEntry *fn_table_entry = fn_scope->fn_entry;
406 if (!fn_table_entry->proto_node)406 if (!fn_table_entry->proto_node)
407 return get_di_scope(g, scope->parent);407 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;
409 unsigned scope_line = line_number;409 unsigned scope_line = line_number;
410 bool is_definition = fn_table_entry->body_node != nullptr;410 bool is_definition = fn_table_entry->body_node != nullptr;
411 unsigned flags = 0;411 unsigned flags = 0;
...@@ -438,8 +438,8 @@ static ZigLLVMDIScope *get_di_scope(CodeGen *g, Scope *scope) {...@@ -438,8 +438,8 @@ static ZigLLVMDIScope *get_di_scope(CodeGen *g, Scope *scope) {
438 ZigLLVMDILexicalBlock *di_block = ZigLLVMCreateLexicalBlock(g->dbuilder,438 ZigLLVMDILexicalBlock *di_block = ZigLLVMCreateLexicalBlock(g->dbuilder,
439 get_di_scope(g, scope->parent),439 get_di_scope(g, scope->parent),
440 import->di_file,440 import->di_file,
441 scope->source_node->line + 1,441 (unsigned)scope->source_node->line + 1,
442 scope->source_node->column + 1);442 (unsigned)scope->source_node->column + 1);
443 scope->di_scope = ZigLLVMLexicalBlockToScope(di_block);443 scope->di_scope = ZigLLVMLexicalBlockToScope(di_block);
444 return scope->di_scope;444 return scope->di_scope;
445 }445 }
...@@ -462,7 +462,7 @@ static LLVMValueRef get_arithmetic_overflow_fn(CodeGen *g, TypeTableEntry *type_...@@ -462,7 +462,7 @@ static LLVMValueRef get_arithmetic_overflow_fn(CodeGen *g, TypeTableEntry *type_
462462
463 assert(type_entry->id == TypeTableEntryIdInt);463 assert(type_entry->id == TypeTableEntryIdInt);
464 const char *signed_str = type_entry->data.integral.is_signed ? signed_name : unsigned_name;464 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
467 LLVMTypeRef return_elem_types[] = {467 LLVMTypeRef return_elem_types[] = {
468 type_entry->type_ref,468 type_entry->type_ref,
...@@ -486,7 +486,7 @@ static LLVMValueRef get_int_overflow_fn(CodeGen *g, TypeTableEntry *type_entry,...@@ -486,7 +486,7 @@ static LLVMValueRef get_int_overflow_fn(CodeGen *g, TypeTableEntry *type_entry,
486 key.id = ZigLLVMFnIdOverflowArithmetic;486 key.id = ZigLLVMFnIdOverflowArithmetic;
487 key.data.overflow_arithmetic.is_signed = type_entry->data.integral.is_signed;487 key.data.overflow_arithmetic.is_signed = type_entry->data.integral.is_signed;
488 key.data.overflow_arithmetic.add_sub_mul = add_sub_mul;488 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
491 auto existing_entry = g->llvm_fn_table.maybe_get(key);491 auto existing_entry = g->llvm_fn_table.maybe_get(key);
492 if (existing_entry)492 if (existing_entry)
...@@ -601,8 +601,8 @@ static void gen_panic(CodeGen *g, LLVMValueRef msg_arg) {...@@ -601,8 +601,8 @@ static void gen_panic(CodeGen *g, LLVMValueRef msg_arg) {
601 TypeTableEntry *str_type = get_slice_type(g, g->builtin_types.entry_u8, true);601 TypeTableEntry *str_type = get_slice_type(g, g->builtin_types.entry_u8, true);
602 size_t ptr_index = str_type->data.structure.fields[slice_ptr_index].gen_index;602 size_t ptr_index = str_type->data.structure.fields[slice_ptr_index].gen_index;
603 size_t len_index = str_type->data.structure.fields[slice_len_index].gen_index;603 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, "");604 LLVMValueRef ptr_ptr = LLVMBuildStructGEP(g->builder, msg_arg, (unsigned)ptr_index, "");
605 LLVMValueRef len_ptr = LLVMBuildStructGEP(g->builder, msg_arg, len_index, "");605 LLVMValueRef len_ptr = LLVMBuildStructGEP(g->builder, msg_arg, (unsigned)len_index, "");
606606
607 LLVMValueRef args[] = {607 LLVMValueRef args[] = {
608 LLVMBuildLoad(g->builder, ptr_ptr, ""),608 LLVMBuildLoad(g->builder, ptr_ptr, ""),
...@@ -891,8 +891,8 @@ static LLVMValueRef gen_assign_raw(CodeGen *g, LLVMValueRef ptr, TypeTableEntry...@@ -891,8 +891,8 @@ static LLVMValueRef gen_assign_raw(CodeGen *g, LLVMValueRef ptr, TypeTableEntry
891891
892static void gen_var_debug_decl(CodeGen *g, VariableTableEntry *var) {892static void gen_var_debug_decl(CodeGen *g, VariableTableEntry *var) {
893 AstNode *source_node = var->decl_node;893 AstNode *source_node = var->decl_node;
894 ZigLLVMDILocation *debug_loc = ZigLLVMGetDebugLoc(source_node->line + 1, source_node->column + 1,894 ZigLLVMDILocation *debug_loc = ZigLLVMGetDebugLoc((unsigned)source_node->line + 1,
895 get_di_scope(g, var->parent_scope));895 (unsigned)source_node->column + 1, get_di_scope(g, var->parent_scope));
896 ZigLLVMInsertDeclareAtEnd(g->dbuilder, var->value_ref, var->di_loc_var, debug_loc,896 ZigLLVMInsertDeclareAtEnd(g->dbuilder, var->value_ref, var->di_loc_var, debug_loc,
897 LLVMGetInsertBlock(g->builder));897 LLVMGetInsertBlock(g->builder));
898}898}
...@@ -1272,20 +1272,20 @@ static LLVMValueRef ir_render_cast(CodeGen *g, IrExecutable *executable,...@@ -1272,20 +1272,20 @@ static LLVMValueRef ir_render_cast(CodeGen *g, IrExecutable *executable,
1272 TypeTableEntry *wanted_child_type = wanted_pointer_type->data.pointer.child_type;1272 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;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[1].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[0].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[1].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, "");
1281 LLVMValueRef src_ptr = LLVMBuildLoad(g->builder, src_ptr_ptr, "");1281 LLVMValueRef src_ptr = LLVMBuildLoad(g->builder, src_ptr_ptr, "");
1282 LLVMValueRef src_ptr_casted = LLVMBuildBitCast(g->builder, src_ptr,1282 LLVMValueRef src_ptr_casted = LLVMBuildBitCast(g->builder, src_ptr,
1283 wanted_type->data.structure.fields[0].type_entry->type_ref, "");1283 wanted_type->data.structure.fields[0].type_entry->type_ref, "");
1284 LLVMValueRef dest_ptr_ptr = LLVMBuildStructGEP(g->builder, cast_instruction->tmp_ptr,1284 LLVMValueRef dest_ptr_ptr = LLVMBuildStructGEP(g->builder, cast_instruction->tmp_ptr,
1285 wanted_ptr_index, "");1285 (unsigned)wanted_ptr_index, "");
1286 LLVMBuildStore(g->builder, src_ptr_casted, dest_ptr_ptr);1286 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, "");
1289 LLVMValueRef src_len = LLVMBuildLoad(g->builder, src_len_ptr, "");1289 LLVMValueRef src_len = LLVMBuildLoad(g->builder, src_len_ptr, "");
1290 uint64_t src_size = type_size(g, actual_child_type);1290 uint64_t src_size = type_size(g, actual_child_type);
1291 uint64_t dest_size = type_size(g, wanted_child_type);1291 uint64_t dest_size = type_size(g, wanted_child_type);
...@@ -1315,7 +1315,7 @@ static LLVMValueRef ir_render_cast(CodeGen *g, IrExecutable *executable,...@@ -1315,7 +1315,7 @@ static LLVMValueRef ir_render_cast(CodeGen *g, IrExecutable *executable,
1315 }1315 }
13161316
1317 LLVMValueRef dest_len_ptr = LLVMBuildStructGEP(g->builder, cast_instruction->tmp_ptr,1317 LLVMValueRef dest_len_ptr = LLVMBuildStructGEP(g->builder, cast_instruction->tmp_ptr,
1318 wanted_len_index, "");1318 (unsigned)wanted_len_index, "");
1319 LLVMBuildStore(g->builder, new_len, dest_len_ptr);1319 LLVMBuildStore(g->builder, new_len, dest_len_ptr);
13201320
13211321
...@@ -1333,12 +1333,14 @@ static LLVMValueRef ir_render_cast(CodeGen *g, IrExecutable *executable,...@@ -1333,12 +1333,14 @@ static LLVMValueRef ir_render_cast(CodeGen *g, IrExecutable *executable,
13331333
13341334
1335 size_t wanted_ptr_index = wanted_type->data.structure.fields[0].gen_index;1335 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, "");
1337 LLVMValueRef src_ptr_casted = LLVMBuildBitCast(g->builder, expr_val, wanted_pointer_type->type_ref, "");1338 LLVMValueRef src_ptr_casted = LLVMBuildBitCast(g->builder, expr_val, wanted_pointer_type->type_ref, "");
1338 LLVMBuildStore(g->builder, src_ptr_casted, dest_ptr_ptr);1339 LLVMBuildStore(g->builder, src_ptr_casted, dest_ptr_ptr);
13391340
1340 size_t wanted_len_index = wanted_type->data.structure.fields[1].gen_index;1341 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, "");
1342 LLVMValueRef len_val = LLVMConstInt(g->builtin_types.entry_usize->type_ref,1344 LLVMValueRef len_val = LLVMConstInt(g->builtin_types.entry_usize->type_ref,
1343 actual_type->data.array.len / type_size(g, wanted_child_type), false);1345 actual_type->data.array.len / type_size(g, wanted_child_type), false);
1344 LLVMBuildStore(g->builder, len_val, len_ptr);1346 LLVMBuildStore(g->builder, len_val, len_ptr);
...@@ -1721,14 +1723,14 @@ static LLVMValueRef ir_render_elem_ptr(CodeGen *g, IrExecutable *executable, IrI...@@ -1721,14 +1723,14 @@ static LLVMValueRef ir_render_elem_ptr(CodeGen *g, IrExecutable *executable, IrI
1721 if (safety_check_on) {1723 if (safety_check_on) {
1722 size_t len_index = array_type->data.structure.fields[1].gen_index;1724 size_t len_index = array_type->data.structure.fields[1].gen_index;
1723 assert(len_index != SIZE_MAX);1725 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, "");
1725 LLVMValueRef len = LLVMBuildLoad(g->builder, len_ptr, "");1727 LLVMValueRef len = LLVMBuildLoad(g->builder, len_ptr, "");
1726 add_bounds_check(g, subscript_value, LLVMIntEQ, nullptr, LLVMIntULT, len);1728 add_bounds_check(g, subscript_value, LLVMIntEQ, nullptr, LLVMIntULT, len);
1727 }1729 }
17281730
1729 size_t ptr_index = array_type->data.structure.fields[0].gen_index;1731 size_t ptr_index = array_type->data.structure.fields[0].gen_index;
1730 assert(ptr_index != SIZE_MAX);1732 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, "");
1732 LLVMValueRef ptr = LLVMBuildLoad(g->builder, ptr_ptr, "");1734 LLVMValueRef ptr = LLVMBuildLoad(g->builder, ptr_ptr, "");
1733 return LLVMBuildInBoundsGEP(g->builder, ptr, &subscript_value, 1, "");1735 return LLVMBuildInBoundsGEP(g->builder, ptr, &subscript_value, 1, "");
1734 } else {1736 } else {
...@@ -1772,12 +1774,12 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr...@@ -1772,12 +1774,12 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr
1772 }1774 }
17731775
1774 LLVMValueRef result = ZigLLVMBuildCall(g->builder, fn_val,1776 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
1777 for (size_t param_i = 0; param_i < fn_type_id->param_count; param_i += 1) {1779 for (size_t param_i = 0; param_i < fn_type_id->param_count; param_i += 1) {
1778 FnGenParamInfo *gen_info = &fn_type->data.fn.gen_param_info[param_i];1780 FnGenParamInfo *gen_info = &fn_type->data.fn.gen_param_info[param_i];
1779 if (gen_info->is_byval) {1781 if (gen_info->is_byval) {
1780 addLLVMCallsiteAttr(result, gen_info->gen_index, "byval");1782 addLLVMCallsiteAttr(result, (unsigned)gen_info->gen_index, "byval");
1781 }1783 }
1782 }1784 }
17831785
...@@ -1810,7 +1812,7 @@ static LLVMValueRef ir_render_struct_field_ptr(CodeGen *g, IrExecutable *executa...@@ -1810,7 +1812,7 @@ static LLVMValueRef ir_render_struct_field_ptr(CodeGen *g, IrExecutable *executa
1810 }1812 }
18111813
1812 assert(field->gen_index != SIZE_MAX);1814 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, "");
1814}1816}
18151817
1816static LLVMValueRef ir_render_enum_field_ptr(CodeGen *g, IrExecutable *executable,1818static LLVMValueRef ir_render_enum_field_ptr(CodeGen *g, IrExecutable *executable,
...@@ -1948,14 +1950,14 @@ static LLVMValueRef ir_render_asm(CodeGen *g, IrExecutable *executable, IrInstru...@@ -1948,14 +1950,14 @@ static LLVMValueRef ir_render_asm(CodeGen *g, IrExecutable *executable, IrInstru
1948 } else {1950 } else {
1949 ret_type = instruction->base.value.type->type_ref;1951 ret_type = instruction->base.value.type->type_ref;
1950 }1952 }
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
1953 bool is_x86 = (g->zig_target.arch.arch == ZigLLVM_x86 || g->zig_target.arch.arch == ZigLLVM_x86_64);1955 bool is_x86 = (g->zig_target.arch.arch == ZigLLVM_x86 || g->zig_target.arch.arch == ZigLLVM_x86_64);
1954 bool is_volatile = asm_expr->is_volatile || (asm_expr->output_list.length == 0);1956 bool is_volatile = asm_expr->is_volatile || (asm_expr->output_list.length == 0);
1955 LLVMValueRef asm_fn = ZigLLVMConstInlineAsm(function_type, buf_ptr(&llvm_template),1957 LLVMValueRef asm_fn = ZigLLVMConstInlineAsm(function_type, buf_ptr(&llvm_template),
1956 buf_ptr(&constraint_buf), is_volatile, false, is_x86);1958 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, "");
1959}1961}
19601962
1961static LLVMValueRef gen_non_null_bit(CodeGen *g, TypeTableEntry *maybe_type, LLVMValueRef maybe_handle) {1963static 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...@@ -2021,11 +2023,11 @@ static LLVMValueRef get_int_builtin_fn(CodeGen *g, TypeTableEntry *int_type, Bui
2021 if (fn_id == BuiltinFnIdCtz) {2023 if (fn_id == BuiltinFnIdCtz) {
2022 fn_name = "cttz";2024 fn_name = "cttz";
2023 key.id = ZigLLVMFnIdCtz;2025 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;
2025 } else {2027 } else {
2026 fn_name = "ctlz";2028 fn_name = "ctlz";
2027 key.id = ZigLLVMFnIdClz;2029 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;
2029 }2031 }
20302032
2031 auto existing_entry = g->llvm_fn_table.maybe_get(key);2033 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...@@ -2033,7 +2035,7 @@ static LLVMValueRef get_int_builtin_fn(CodeGen *g, TypeTableEntry *int_type, Bui
2033 return existing_entry->value;2035 return existing_entry->value;
20342036
2035 char llvm_name[64];2037 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);
2037 LLVMTypeRef param_types[] = {2039 LLVMTypeRef param_types[] = {
2038 int_type->type_ref,2040 int_type->type_ref,
2039 LLVMInt1Type(),2041 LLVMInt1Type(),
...@@ -2071,7 +2073,8 @@ static LLVMValueRef ir_render_ctz(CodeGen *g, IrExecutable *executable, IrInstru...@@ -2071,7 +2073,8 @@ static LLVMValueRef ir_render_ctz(CodeGen *g, IrExecutable *executable, IrInstru
2071static LLVMValueRef ir_render_switch_br(CodeGen *g, IrExecutable *executable, IrInstructionSwitchBr *instruction) {2073static LLVMValueRef ir_render_switch_br(CodeGen *g, IrExecutable *executable, IrInstructionSwitchBr *instruction) {
2072 LLVMValueRef target_value = ir_llvm_value(g, instruction->target_value);2074 LLVMValueRef target_value = ir_llvm_value(g, instruction->target_value);
2073 LLVMBasicBlockRef else_block = instruction->else_block->llvm_block;2075 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);
2075 for (size_t i = 0; i < instruction->case_count; i += 1) {2078 for (size_t i = 0; i < instruction->case_count; i += 1) {
2076 IrInstructionSwitchBrCase *this_case = &instruction->cases[i];2079 IrInstructionSwitchBrCase *this_case = &instruction->cases[i];
2077 LLVMAddCase(switch_instr, ir_llvm_value(g, this_case->value), this_case->block->llvm_block);2080 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...@@ -2097,7 +2100,7 @@ static LLVMValueRef ir_render_phi(CodeGen *g, IrExecutable *executable, IrInstru
2097 incoming_values[i] = ir_llvm_value(g, instruction->incoming_values[i]);2100 incoming_values[i] = ir_llvm_value(g, instruction->incoming_values[i]);
2098 incoming_blocks[i] = instruction->incoming_blocks[i]->llvm_exit_block;2101 incoming_blocks[i] = instruction->incoming_blocks[i]->llvm_exit_block;
2099 }2102 }
2100 LLVMAddIncoming(phi, incoming_values, incoming_blocks, instruction->incoming_count);2103 LLVMAddIncoming(phi, incoming_values, incoming_blocks, (unsigned)instruction->incoming_count);
2101 return phi;2104 return phi;
2102}2105}
21032106
...@@ -2337,14 +2340,14 @@ static LLVMValueRef ir_render_slice(CodeGen *g, IrExecutable *executable, IrInst...@@ -2337,14 +2340,14 @@ static LLVMValueRef ir_render_slice(CodeGen *g, IrExecutable *executable, IrInst
2337 assert(LLVMGetTypeKind(LLVMTypeOf(array_ptr)) == LLVMPointerTypeKind);2340 assert(LLVMGetTypeKind(LLVMTypeOf(array_ptr)) == LLVMPointerTypeKind);
2338 assert(LLVMGetTypeKind(LLVMGetElementType(LLVMTypeOf(array_ptr))) == LLVMStructTypeKind);2341 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;
2341 assert(ptr_index != SIZE_MAX);2344 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;
2343 assert(len_index != SIZE_MAX);2346 assert(len_index != SIZE_MAX);
23442347
2345 LLVMValueRef prev_end = nullptr;2348 LLVMValueRef prev_end = nullptr;
2346 if (!instruction->end || want_debug_safety) {2349 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, "");
2348 prev_end = LLVMBuildLoad(g->builder, src_len_ptr, "");2351 prev_end = LLVMBuildLoad(g->builder, src_len_ptr, "");
2349 }2352 }
23502353
...@@ -2364,13 +2367,13 @@ static LLVMValueRef ir_render_slice(CodeGen *g, IrExecutable *executable, IrInst...@@ -2364,13 +2367,13 @@ static LLVMValueRef ir_render_slice(CodeGen *g, IrExecutable *executable, IrInst
2364 }2367 }
2365 }2368 }
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, "");
2368 LLVMValueRef src_ptr = LLVMBuildLoad(g->builder, src_ptr_ptr, "");2371 LLVMValueRef src_ptr = LLVMBuildLoad(g->builder, src_ptr_ptr, "");
2369 LLVMValueRef ptr_field_ptr = LLVMBuildStructGEP(g->builder, tmp_struct_ptr, ptr_index, "");2372 LLVMValueRef ptr_field_ptr = LLVMBuildStructGEP(g->builder, tmp_struct_ptr, (unsigned)ptr_index, "");
2370 LLVMValueRef slice_start_ptr = LLVMBuildInBoundsGEP(g->builder, src_ptr, &start_val, len_index, "");2373 LLVMValueRef slice_start_ptr = LLVMBuildInBoundsGEP(g->builder, src_ptr, &start_val, (unsigned)len_index, "");
2371 LLVMBuildStore(g->builder, slice_start_ptr, ptr_field_ptr);2374 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, "");
2374 LLVMValueRef len_value = LLVMBuildNSWSub(g->builder, end_val, start_val, "");2377 LLVMValueRef len_value = LLVMBuildNSWSub(g->builder, end_val, start_val, "");
2375 LLVMBuildStore(g->builder, len_value, len_field_ptr);2378 LLVMBuildStore(g->builder, len_value, len_field_ptr);
23762379
...@@ -2650,12 +2653,13 @@ static LLVMValueRef ir_render_struct_init(CodeGen *g, IrExecutable *executable,...@@ -2650,12 +2653,13 @@ static LLVMValueRef ir_render_struct_init(CodeGen *g, IrExecutable *executable,
2650 if (!type_has_bits(type_struct_field->type_entry))2653 if (!type_has_bits(type_struct_field->type_entry))
2651 continue;2654 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, "");
2654 LLVMValueRef value = ir_llvm_value(g, field->value);2658 LLVMValueRef value = ir_llvm_value(g, field->value);
26552659
2656 TypeTableEntry *ptr_type = get_pointer_to_type_extra(g, type_struct_field->type_entry,2660 TypeTableEntry *ptr_type = get_pointer_to_type_extra(g, type_struct_field->type_entry,
2657 false, false,2661 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
2660 gen_assign_raw(g, field_ptr, ptr_type, value);2664 gen_assign_raw(g, field_ptr, ptr_type, value);
2661 }2665 }
...@@ -2698,7 +2702,8 @@ static void set_debug_location(CodeGen *g, IrInstruction *instruction) {...@@ -2698,7 +2702,8 @@ static void set_debug_location(CodeGen *g, IrInstruction *instruction) {
2698 assert(source_node);2702 assert(source_node);
2699 assert(scope);2703 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));
2702}2707}
27032708
2704static LLVMValueRef ir_render_instruction(CodeGen *g, IrExecutable *executable, IrInstruction *instruction) {2709static 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...@@ -2964,7 +2969,8 @@ static LLVMValueRef pack_const_int(CodeGen *g, LLVMTypeRef big_int_type_ref, Con
2964 case TypeTableEntryIdFloat:2969 case TypeTableEntryIdFloat:
2965 {2970 {
2966 LLVMValueRef float_val = gen_const_val(g, const_val);2971 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));
2968 return LLVMConstZExt(int_val, big_int_type_ref);2974 return LLVMConstZExt(int_val, big_int_type_ref);
2969 }2975 }
2970 case TypeTableEntryIdPointer:2976 case TypeTableEntryIdPointer:
...@@ -3027,7 +3033,7 @@ static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val) {...@@ -3027,7 +3033,7 @@ static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val) {
3027 if (const_val->data.x_bignum.kind == BigNumKindFloat) {3033 if (const_val->data.x_bignum.kind == BigNumKindFloat) {
3028 return LLVMConstReal(canon_type->type_ref, const_val->data.x_bignum.data.x_float);3034 return LLVMConstReal(canon_type->type_ref, const_val->data.x_bignum.data.x_float);
3029 } else {3035 } 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;
3031 if (const_val->data.x_bignum.is_negative) {3037 if (const_val->data.x_bignum.is_negative) {
3032 x = -x;3038 x = -x;
3033 }3039 }
...@@ -3094,7 +3100,7 @@ static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val) {...@@ -3094,7 +3100,7 @@ static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val) {
3094 gen_const_val(g, &const_val->data.x_struct.fields[src_field_index]);3100 gen_const_val(g, &const_val->data.x_struct.fields[src_field_index]);
3095 } else {3101 } else {
3096 LLVMTypeRef big_int_type_ref = LLVMStructGetTypeAtIndex(canon_type->type_ref,3102 LLVMTypeRef big_int_type_ref = LLVMStructGetTypeAtIndex(canon_type->type_ref,
3097 type_struct_field->gen_index);3103 (unsigned)type_struct_field->gen_index);
3098 LLVMValueRef val = LLVMConstInt(big_int_type_ref, 0, false);3104 LLVMValueRef val = LLVMConstInt(big_int_type_ref, 0, false);
3099 for (size_t i = src_field_index; i < src_field_index_end; i += 1) {3105 for (size_t i = src_field_index; i < src_field_index_end; i += 1) {
3100 TypeStructField *it_field = &canon_type->data.structure.fields[i];3106 TypeStructField *it_field = &canon_type->data.structure.fields[i];
...@@ -3136,7 +3142,7 @@ static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val) {...@@ -3136,7 +3142,7 @@ static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val) {
3136 ConstExprValue *elem_value = &const_val->data.x_array.elements[i];3142 ConstExprValue *elem_value = &const_val->data.x_array.elements[i];
3137 values[i] = gen_const_val(g, elem_value);3143 values[i] = gen_const_val(g, elem_value);
3138 }3144 }
3139 return LLVMConstArray(LLVMTypeOf(values[0]), values, len);3145 return LLVMConstArray(LLVMTypeOf(values[0]), values, (unsigned)len);
3140 }3146 }
3141 case TypeTableEntryIdEnum:3147 case TypeTableEntryIdEnum:
3142 {3148 {
...@@ -3162,7 +3168,7 @@ static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val) {...@@ -3162,7 +3168,7 @@ static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val) {
3162 } else {3168 } else {
3163 LLVMValueRef fields[] = {3169 LLVMValueRef fields[] = {
3164 correctly_typed_value,3170 correctly_typed_value,
3165 LLVMGetUndef(LLVMArrayType(LLVMInt8Type(), pad_bytes)),3171 LLVMGetUndef(LLVMArrayType(LLVMInt8Type(), (unsigned)pad_bytes)),
3166 };3172 };
3167 union_value = LLVMConstStruct(fields, 2, false);3173 union_value = LLVMConstStruct(fields, 2, false);
3168 }3174 }
...@@ -3352,7 +3358,7 @@ static bool should_skip_fn_codegen(CodeGen *g, FnTableEntry *fn_entry) {...@@ -3352,7 +3358,7 @@ static bool should_skip_fn_codegen(CodeGen *g, FnTableEntry *fn_entry) {
3352static LLVMValueRef gen_test_fn_val(CodeGen *g, FnTableEntry *fn_entry) {3358static LLVMValueRef gen_test_fn_val(CodeGen *g, FnTableEntry *fn_entry) {
3353 // Must match TestFn struct from test_runner.zig3359 // Must match TestFn struct from test_runner.zig
3354 Buf *fn_name = &fn_entry->symbol_name;3360 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);
3356 LLVMValueRef str_global_val = LLVMAddGlobal(g->module, LLVMTypeOf(str_init), "");3362 LLVMValueRef str_global_val = LLVMAddGlobal(g->module, LLVMTypeOf(str_init), "");
3357 LLVMSetInitializer(str_global_val, str_init);3363 LLVMSetInitializer(str_global_val, str_init);
3358 LLVMSetLinkage(str_global_val, LLVMPrivateLinkage);3364 LLVMSetLinkage(str_global_val, LLVMPrivateLinkage);
...@@ -3392,7 +3398,7 @@ static void generate_error_name_table(CodeGen *g) {...@@ -3392,7 +3398,7 @@ static void generate_error_name_table(CodeGen *g) {
3392 assert(error_decl_node->type == NodeTypeErrorValueDecl);3398 assert(error_decl_node->type == NodeTypeErrorValueDecl);
3393 Buf *name = error_decl_node->data.error_value_decl.name;3399 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);
3396 LLVMValueRef str_global = LLVMAddGlobal(g->module, LLVMTypeOf(str_init), "");3402 LLVMValueRef str_global = LLVMAddGlobal(g->module, LLVMTypeOf(str_init), "");
3397 LLVMSetInitializer(str_global, str_init);3403 LLVMSetInitializer(str_global, str_init);
3398 LLVMSetLinkage(str_global, LLVMPrivateLinkage);3404 LLVMSetLinkage(str_global, LLVMPrivateLinkage);
...@@ -3406,7 +3412,7 @@ static void generate_error_name_table(CodeGen *g) {...@@ -3406,7 +3412,7 @@ static void generate_error_name_table(CodeGen *g) {
3406 values[i] = LLVMConstNamedStruct(str_type->type_ref, fields, 2);3412 values[i] = LLVMConstNamedStruct(str_type->type_ref, fields, 2);
3407 }3413 }
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
3411 g->err_name_table = LLVMAddGlobal(g->module, LLVMTypeOf(err_name_table_init),3417 g->err_name_table = LLVMAddGlobal(g->module, LLVMTypeOf(err_name_table_init),
3412 buf_ptr(get_mangled_name(g, buf_create_from_str("err_name_table"), false)));3418 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) {...@@ -3430,7 +3436,7 @@ static void generate_enum_name_tables(CodeGen *g) {
3430 for (size_t field_i = 0; field_i < field_count; field_i += 1) {3436 for (size_t field_i = 0; field_i < field_count; field_i += 1) {
3431 Buf *name = enum_type->data.enumeration.fields[field_i].name;3437 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);
3434 LLVMValueRef str_global = LLVMAddGlobal(g->module, LLVMTypeOf(str_init), "");3440 LLVMValueRef str_global = LLVMAddGlobal(g->module, LLVMTypeOf(str_init), "");
3435 LLVMSetInitializer(str_global, str_init);3441 LLVMSetInitializer(str_global, str_init);
3436 LLVMSetLinkage(str_global, LLVMPrivateLinkage);3442 LLVMSetLinkage(str_global, LLVMPrivateLinkage);
...@@ -3444,7 +3450,7 @@ static void generate_enum_name_tables(CodeGen *g) {...@@ -3444,7 +3450,7 @@ static void generate_enum_name_tables(CodeGen *g) {
3444 values[field_i] = LLVMConstNamedStruct(str_type->type_ref, fields, 2);3450 values[field_i] = LLVMConstNamedStruct(str_type->type_ref, fields, 2);
3445 }3451 }
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
3449 Buf *table_name = get_mangled_name(g, buf_sprintf("%s_name_table", buf_ptr(&enum_type->name)), false);3455 Buf *table_name = get_mangled_name(g, buf_sprintf("%s_name_table", buf_ptr(&enum_type->name)), false);
3450 LLVMValueRef name_table = LLVMAddGlobal(g->module, LLVMTypeOf(name_table_init), buf_ptr(table_name));3456 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...@@ -3478,7 +3484,8 @@ static void gen_global_var(CodeGen *g, VariableTableEntry *var, LLVMValueRef ini
34783484
3479 bool is_local_to_unit = true;3485 bool is_local_to_unit = true;
3480 ZigLLVMCreateGlobalVariable(g->dbuilder, get_di_scope(g, var->parent_scope), buf_ptr(&var->name),3486 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),
3482 type_entry->di_type, is_local_to_unit);3489 type_entry->di_type, is_local_to_unit);
3483 // TODO ^^ make an actual global variable3490 // TODO ^^ make an actual global variable
3484}3491}
...@@ -3606,16 +3613,16 @@ static void do_code_gen(CodeGen *g) {...@@ -3606,16 +3613,16 @@ static void do_code_gen(CodeGen *g) {
36063613
3607 TypeTableEntry *param_type = gen_info->type;3614 TypeTableEntry *param_type = gen_info->type;
3608 if (param_info->is_noalias) {3615 if (param_info->is_noalias) {
3609 addLLVMArgAttr(fn_val, gen_index, "noalias");3616 addLLVMArgAttr(fn_val, (unsigned)gen_index, "noalias");
3610 }3617 }
3611 if ((param_type->id == TypeTableEntryIdPointer && param_type->data.pointer.is_const) || is_byval) {3618 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");
3613 }3620 }
3614 if (param_type->id == TypeTableEntryIdPointer) {3621 if (param_type->id == TypeTableEntryIdPointer) {
3615 addLLVMArgAttr(fn_val, gen_index, "nonnull");3622 addLLVMArgAttr(fn_val, (unsigned)gen_index, "nonnull");
3616 }3623 }
3617 if (is_byval) {3624 if (is_byval) {
3618 addLLVMArgAttr(fn_val, gen_index, "byval");3625 addLLVMArgAttr(fn_val, (unsigned)gen_index, "byval");
3619 }3626 }
3620 }3627 }
36213628
...@@ -3737,7 +3744,7 @@ static void do_code_gen(CodeGen *g) {...@@ -3737,7 +3744,7 @@ static void do_code_gen(CodeGen *g) {
3737 var->value_ref = build_alloca(g, var->value->type, buf_ptr(&var->name));3744 var->value_ref = build_alloca(g, var->value->type, buf_ptr(&var->name));
37383745
3739 var->di_loc_var = ZigLLVMCreateAutoVariable(g->dbuilder, get_di_scope(g, var->parent_scope),3746 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),
3741 var->value->type->di_type, !g->strip_debug_symbols, 0);3748 var->value->type->di_type, !g->strip_debug_symbols, 0);
37423749
3743 } else {3750 } else {
...@@ -3751,15 +3758,16 @@ static void do_code_gen(CodeGen *g) {...@@ -3751,15 +3758,16 @@ static void do_code_gen(CodeGen *g) {
3751 } else {3758 } else {
3752 gen_type = gen_info->type;3759 gen_type = gen_info->type;
3753 }3760 }
3754 var->value_ref = LLVMGetParam(fn, var->gen_arg_index);3761 var->value_ref = LLVMGetParam(fn, (unsigned)var->gen_arg_index);
3755 } else {3762 } else {
3756 gen_type = var->value->type;3763 gen_type = var->value->type;
3757 var->value_ref = build_alloca(g, var->value->type, buf_ptr(&var->name));3764 var->value_ref = build_alloca(g, var->value->type, buf_ptr(&var->name));
3758 }3765 }
3759 if (var->decl_node) {3766 if (var->decl_node) {
3760 var->di_loc_var = ZigLLVMCreateParameterVariable(g->dbuilder, get_di_scope(g, var->parent_scope),3767 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,3768 buf_ptr(&var->name), import->di_file,
3762 gen_type->di_type, !g->strip_debug_symbols, 0, var->gen_arg_index + 1);3769 (unsigned)(var->decl_node->line + 1),
3770 gen_type->di_type, !g->strip_debug_symbols, 0, (unsigned)(var->gen_arg_index + 1));
3763 }3771 }
37643772
3765 }3773 }
...@@ -3784,7 +3792,7 @@ static void do_code_gen(CodeGen *g) {...@@ -3784,7 +3792,7 @@ static void do_code_gen(CodeGen *g) {
37843792
3785 if (!handle_is_ptr(variable->value->type)) {3793 if (!handle_is_ptr(variable->value->type)) {
3786 clear_debug_source_node(g);3794 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);
3788 }3796 }
37893797
3790 if (variable->decl_node) {3798 if (variable->decl_node) {
...@@ -3827,7 +3835,7 @@ static void do_code_gen(CodeGen *g) {...@@ -3827,7 +3835,7 @@ static void do_code_gen(CodeGen *g) {
3827 g->link_objects.append(out_file_o);3835 g->link_objects.append(out_file_o);
3828}3836}
38293837
3830static const size_t int_sizes_in_bits[] = {3838static const uint8_t int_sizes_in_bits[] = {
3831 8,3839 8,
3832 16,3840 16,
3833 32,3841 32,
...@@ -3950,7 +3958,7 @@ static void define_builtin_types(CodeGen *g) {...@@ -3950,7 +3958,7 @@ static void define_builtin_types(CodeGen *g) {
3950 }3958 }
39513959
3952 for (size_t int_size_i = 0; int_size_i < array_length(int_sizes_in_bits); int_size_i += 1) {3960 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];
3954 for (size_t is_sign_i = 0; is_sign_i < array_length(is_signed_list); is_sign_i += 1) {3962 for (size_t is_sign_i = 0; is_sign_i < array_length(is_signed_list); is_sign_i += 1) {
3955 bool is_signed = is_signed_list[is_sign_i];3963 bool is_signed = is_signed_list[is_sign_i];
3956 TypeTableEntry *entry = make_int_type(g, is_signed, size_in_bits);3964 TypeTableEntry *entry = make_int_type(g, is_signed, size_in_bits);
...@@ -3961,7 +3969,7 @@ static void define_builtin_types(CodeGen *g) {...@@ -3961,7 +3969,7 @@ static void define_builtin_types(CodeGen *g) {
39613969
3962 for (size_t i = 0; i < array_length(c_int_type_infos); i += 1) {3970 for (size_t i = 0; i < array_length(c_int_type_infos); i += 1) {
3963 const CIntTypeInfo *info = &c_int_type_infos[i];3971 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);
3965 bool is_signed = info->is_signed;3973 bool is_signed = info->is_signed;
39663974
3967 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdInt);3975 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdInt);
...@@ -4116,7 +4124,7 @@ static void define_builtin_types(CodeGen *g) {...@@ -4116,7 +4124,7 @@ static void define_builtin_types(CodeGen *g) {
4116 {4124 {
4117 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdEnum);4125 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdEnum);
4118 buf_init_from_str(&entry->name, "Os");4126 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();
4120 entry->data.enumeration.src_field_count = field_count;4128 entry->data.enumeration.src_field_count = field_count;
4121 entry->data.enumeration.fields = allocate<TypeEnumField>(field_count);4129 entry->data.enumeration.fields = allocate<TypeEnumField>(field_count);
4122 for (uint32_t i = 0; i < field_count; i += 1) {4130 for (uint32_t i = 0; i < field_count; i += 1) {
...@@ -4140,7 +4148,7 @@ static void define_builtin_types(CodeGen *g) {...@@ -4140,7 +4148,7 @@ static void define_builtin_types(CodeGen *g) {
4140 {4148 {
4141 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdEnum);4149 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdEnum);
4142 buf_init_from_str(&entry->name, "Arch");4150 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();
4144 entry->data.enumeration.src_field_count = field_count;4152 entry->data.enumeration.src_field_count = field_count;
4145 entry->data.enumeration.fields = allocate<TypeEnumField>(field_count);4153 entry->data.enumeration.fields = allocate<TypeEnumField>(field_count);
4146 for (uint32_t i = 0; i < field_count; i += 1) {4154 for (uint32_t i = 0; i < field_count; i += 1) {
...@@ -4170,7 +4178,7 @@ static void define_builtin_types(CodeGen *g) {...@@ -4170,7 +4178,7 @@ static void define_builtin_types(CodeGen *g) {
4170 {4178 {
4171 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdEnum);4179 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdEnum);
4172 buf_init_from_str(&entry->name, "Environ");4180 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();
4174 entry->data.enumeration.src_field_count = field_count;4182 entry->data.enumeration.src_field_count = field_count;
4175 entry->data.enumeration.fields = allocate<TypeEnumField>(field_count);4183 entry->data.enumeration.fields = allocate<TypeEnumField>(field_count);
4176 for (uint32_t i = 0; i < field_count; i += 1) {4184 for (uint32_t i = 0; i < field_count; i += 1) {
...@@ -4194,7 +4202,7 @@ static void define_builtin_types(CodeGen *g) {...@@ -4194,7 +4202,7 @@ static void define_builtin_types(CodeGen *g) {
4194 {4202 {
4195 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdEnum);4203 TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdEnum);
4196 buf_init_from_str(&entry->name, "ObjectFormat");4204 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();
4198 entry->data.enumeration.src_field_count = field_count;4206 entry->data.enumeration.src_field_count = field_count;
4199 entry->data.enumeration.fields = allocate<TypeEnumField>(field_count);4207 entry->data.enumeration.fields = allocate<TypeEnumField>(field_count);
4200 for (uint32_t i = 0; i < field_count; i += 1) {4208 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) {...@@ -4705,7 +4713,7 @@ static void get_c_type(CodeGen *g, TypeTableEntry *type_entry, Buf *out_buf) {
4705 case TypeTableEntryIdInt:4713 case TypeTableEntryIdInt:
4706 g->c_want_stdint = true;4714 g->c_want_stdint = true;
4707 buf_resize(out_buf, 0);4715 buf_resize(out_buf, 0);
4708 buf_appendf(out_buf, "%sint%zu_t",4716 buf_appendf(out_buf, "%sint%" PRIu32 "_t",
4709 type_entry->data.integral.is_signed ? "" : "u",4717 type_entry->data.integral.is_signed ? "" : "u",
4710 type_entry->data.integral.bit_count);4718 type_entry->data.integral.bit_count);
4711 break;4719 break;
src/ir.cpp+7-6
...@@ -7295,7 +7295,7 @@ static Buf *ir_resolve_str(IrAnalyze *ira, IrInstruction *value) {...@@ -7295,7 +7295,7 @@ static Buf *ir_resolve_str(IrAnalyze *ira, IrInstruction *value) {
7295 ConstExprValue *char_val = &array_val->data.x_array.elements[new_index];7295 ConstExprValue *char_val = &array_val->data.x_array.elements[new_index];
7296 uint64_t big_c = char_val->data.x_bignum.data.x_uint;7296 uint64_t big_c = char_val->data.x_bignum.data.x_uint;
7297 assert(big_c <= UINT8_MAX);7297 assert(big_c <= UINT8_MAX);
7298 uint8_t c = big_c;7298 uint8_t c = (uint8_t)big_c;
7299 buf_ptr(result)[i] = c;7299 buf_ptr(result)[i] = c;
7300 }7300 }
7301 return result;7301 return result;
...@@ -9062,7 +9062,7 @@ static TypeTableEntry *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruc...@@ -9062,7 +9062,7 @@ static TypeTableEntry *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruc
90629062
9063 return_type = get_pointer_to_type_extra(ira->codegen, child_type,9063 return_type = get_pointer_to_type_extra(ira->codegen, child_type,
9064 ptr_type->data.pointer.is_const, ptr_type->data.pointer.is_volatile,9064 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);
9066 }9066 }
9067 } else if (array_type->id == TypeTableEntryIdPointer) {9067 } else if (array_type->id == TypeTableEntryIdPointer) {
9068 return_type = array_type;9068 return_type = array_type;
...@@ -9299,7 +9299,8 @@ static TypeTableEntry *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field...@@ -9299,7 +9299,8 @@ static TypeTableEntry *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field
9299 field->unaligned_bit_count : type_size_bits(ira->codegen, field->type_entry);9299 field->unaligned_bit_count : type_size_bits(ira->codegen, field->type_entry);
9300 ir_build_struct_field_ptr_from(&ira->new_irb, &field_ptr_instruction->base, container_ptr, field);9300 ir_build_struct_field_ptr_from(&ira->new_irb, &field_ptr_instruction->base, container_ptr, field);
9301 return get_pointer_to_type_extra(ira->codegen, field->type_entry, is_const, is_volatile,9301 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);
9303 } else {9304 } else {
9304 return ir_analyze_container_member_access_inner(ira, bare_type, field_name,9305 return ir_analyze_container_member_access_inner(ira, bare_type, field_name,
9305 field_ptr_instruction, container_ptr, container_type);9306 field_ptr_instruction, container_ptr, container_type);
...@@ -9759,7 +9760,7 @@ static TypeTableEntry *ir_analyze_instruction_set_global_align(IrAnalyze *ira,...@@ -9759,7 +9760,7 @@ static TypeTableEntry *ir_analyze_instruction_set_global_align(IrAnalyze *ira,
9759 }9760 }
97609761
9761 AstNode **set_global_align_node;9762 AstNode **set_global_align_node;
9762 uint64_t *alignment_ptr;9763 uint32_t *alignment_ptr;
9763 if (tld->id == TldIdVar) {9764 if (tld->id == TldIdVar) {
9764 TldVar *tld_var = (TldVar *)tld;9765 TldVar *tld_var = (TldVar *)tld;
9765 set_global_align_node = &tld_var->set_global_align_node;9766 set_global_align_node = &tld_var->set_global_align_node;
...@@ -9782,7 +9783,7 @@ static TypeTableEntry *ir_analyze_instruction_set_global_align(IrAnalyze *ira,...@@ -9782,7 +9783,7 @@ static TypeTableEntry *ir_analyze_instruction_set_global_align(IrAnalyze *ira,
9782 return ira->codegen->builtin_types.entry_invalid;9783 return ira->codegen->builtin_types.entry_invalid;
9783 }9784 }
9784 *set_global_align_node = source_node;9785 *set_global_align_node = source_node;
9785 *alignment_ptr = scalar_align;9786 *alignment_ptr = (uint32_t)scalar_align;
97869787
9787 ir_build_const_from(ira, &instruction->base);9788 ir_build_const_from(ira, &instruction->base);
9788 return ira->codegen->builtin_types.entry_void;9789 return ira->codegen->builtin_types.entry_void;
...@@ -11547,7 +11548,7 @@ static TypeTableEntry *ir_analyze_instruction_int_type(IrAnalyze *ira, IrInstruc...@@ -11547,7 +11548,7 @@ static TypeTableEntry *ir_analyze_instruction_int_type(IrAnalyze *ira, IrInstruc
11547 return ira->codegen->builtin_types.entry_invalid;11548 return ira->codegen->builtin_types.entry_invalid;
1154811549
11549 ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);11550 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);
11551 return ira->codegen->builtin_types.entry_type;11552 return ira->codegen->builtin_types.entry_type;
11552}11553}
1155311554
src/link.cpp+3-3
...@@ -503,21 +503,21 @@ static bool darwin_get_release_version(const char *str, int *major, int *minor,...@@ -503,21 +503,21 @@ static bool darwin_get_release_version(const char *str, int *major, int *minor,
503 return false;503 return false;
504504
505 char *end;505 char *end;
506 *major = strtol(str, &end, 10);506 *major = (int)strtol(str, &end, 10);
507 if (*str != '\0' && *end == '\0')507 if (*str != '\0' && *end == '\0')
508 return true;508 return true;
509 if (*end != '.')509 if (*end != '.')
510 return false;510 return false;
511511
512 str = end + 1;512 str = end + 1;
513 *minor = strtol(str, &end, 10);513 *minor = (int)strtol(str, &end, 10);
514 if (*str != '\0' && *end == '\0')514 if (*str != '\0' && *end == '\0')
515 return true;515 return true;
516 if (*end != '.')516 if (*end != '.')
517 return false;517 return false;
518518
519 str = end + 1;519 str = end + 1;
520 *micro = strtol(str, &end, 10);520 *micro = (int)strtol(str, &end, 10);
521 if (*str != '\0' && *end == '\0')521 if (*str != '\0' && *end == '\0')
522 return true;522 return true;
523 if (str == end)523 if (str == end)
src/list.hpp+1-1
...@@ -69,7 +69,7 @@ struct ZigList {...@@ -69,7 +69,7 @@ struct ZigList {
6969
70 size_t better_capacity = capacity;70 size_t better_capacity = capacity;
71 do {71 do {
72 better_capacity = better_capacity * 1.4 + 8;72 better_capacity = better_capacity * 5 / 2 + 8;
73 } while (better_capacity < new_capacity);73 } while (better_capacity < new_capacity);
7474
75 items = reallocate_nonzero(items, capacity, better_capacity);75 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...@@ -556,7 +556,7 @@ static int os_buf_to_tmp_file_posix(Buf *contents, Buf *suffix, Buf *out_tmp_pat
556 buf_resize(out_tmp_path, 0);556 buf_resize(out_tmp_path, 0);
557 buf_appendf(out_tmp_path, "%s/XXXXXX%s", tmp_dir, buf_ptr(suffix));557 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));
560 if (fd < 0) {560 if (fd < 0) {
561 return ErrorFileSystem;561 return ErrorFileSystem;
562 }562 }
...@@ -629,5 +629,5 @@ int os_delete_file(Buf *path) {...@@ -629,5 +629,5 @@ int os_delete_file(Buf *path) {
629}629}
630630
631void os_init(void) {631void os_init(void) {
632 srand(time(NULL));632 srand((unsigned)time(NULL));
633}633}
src/target.cpp+6-6
...@@ -161,7 +161,7 @@ size_t target_oformat_count(void) {...@@ -161,7 +161,7 @@ size_t target_oformat_count(void) {
161 return array_length(oformat_list);161 return array_length(oformat_list);
162}162}
163163
164const ZigLLVM_ObjectFormatType get_target_oformat(int index) {164const ZigLLVM_ObjectFormatType get_target_oformat(size_t index) {
165 return oformat_list[index];165 return oformat_list[index];
166}166}
167167
...@@ -179,7 +179,7 @@ size_t target_arch_count(void) {...@@ -179,7 +179,7 @@ size_t target_arch_count(void) {
179 return array_length(arch_list);179 return array_length(arch_list);
180}180}
181181
182const ArchType *get_target_arch(int index) {182const ArchType *get_target_arch(size_t index) {
183 return &arch_list[index];183 return &arch_list[index];
184}184}
185185
...@@ -187,14 +187,14 @@ size_t target_vendor_count(void) {...@@ -187,14 +187,14 @@ size_t target_vendor_count(void) {
187 return array_length(vendor_list);187 return array_length(vendor_list);
188}188}
189189
190ZigLLVM_VendorType get_target_vendor(int index) {190ZigLLVM_VendorType get_target_vendor(size_t index) {
191 return vendor_list[index];191 return vendor_list[index];
192}192}
193193
194size_t target_os_count(void) {194size_t target_os_count(void) {
195 return array_length(os_list);195 return array_length(os_list);
196}196}
197ZigLLVM_OSType get_target_os(int index) {197ZigLLVM_OSType get_target_os(size_t index) {
198 return os_list[index];198 return os_list[index];
199}199}
200200
...@@ -205,7 +205,7 @@ const char *get_target_os_name(ZigLLVM_OSType os_type) {...@@ -205,7 +205,7 @@ const char *get_target_os_name(ZigLLVM_OSType os_type) {
205size_t target_environ_count(void) {205size_t target_environ_count(void) {
206 return array_length(environ_list);206 return array_length(environ_list);
207}207}
208ZigLLVM_EnvironmentType get_target_environ(int index) {208ZigLLVM_EnvironmentType get_target_environ(size_t index) {
209 return environ_list[index];209 return environ_list[index];
210}210}
211211
...@@ -443,7 +443,7 @@ static int get_arch_pointer_bit_width(ZigLLVM_ArchType arch) {...@@ -443,7 +443,7 @@ static int get_arch_pointer_bit_width(ZigLLVM_ArchType arch) {
443 zig_unreachable();443 zig_unreachable();
444}444}
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) {
447 switch (target->os) {447 switch (target->os) {
448 case ZigLLVM_UnknownOS:448 case ZigLLVM_UnknownOS:
449 switch (id) {449 switch (id) {
src/target.hpp+6-6
...@@ -39,22 +39,22 @@ enum CIntType {...@@ -39,22 +39,22 @@ enum CIntType {
39};39};
4040
41size_t target_arch_count(void);41size_t target_arch_count(void);
42const ArchType *get_target_arch(int index);42const ArchType *get_target_arch(size_t index);
43void get_arch_name(char *out_str, const ArchType *arch);43void get_arch_name(char *out_str, const ArchType *arch);
4444
45size_t target_vendor_count(void);45size_t target_vendor_count(void);
46ZigLLVM_VendorType get_target_vendor(int index);46ZigLLVM_VendorType get_target_vendor(size_t index);
4747
48size_t target_os_count(void);48size_t target_os_count(void);
49ZigLLVM_OSType get_target_os(int index);49ZigLLVM_OSType get_target_os(size_t index);
50const char *get_target_os_name(ZigLLVM_OSType os_type);50const char *get_target_os_name(ZigLLVM_OSType os_type);
5151
52size_t target_environ_count(void);52size_t target_environ_count(void);
53ZigLLVM_EnvironmentType get_target_environ(int index);53ZigLLVM_EnvironmentType get_target_environ(size_t index);
5454
5555
56size_t target_oformat_count(void);56size_t target_oformat_count(void);
57const ZigLLVM_ObjectFormatType get_target_oformat(int index);57const ZigLLVM_ObjectFormatType get_target_oformat(size_t index);
58const char *get_target_oformat_name(ZigLLVM_ObjectFormatType oformat);58const char *get_target_oformat_name(ZigLLVM_ObjectFormatType oformat);
5959
60void get_native_target(ZigTarget *target);60void get_native_target(ZigTarget *target);
...@@ -70,7 +70,7 @@ void get_target_triple(Buf *triple, const ZigTarget *target);...@@ -70,7 +70,7 @@ void get_target_triple(Buf *triple, const ZigTarget *target);
7070
71void resolve_target_object_format(ZigTarget *target);71void 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
75const char *target_o_file_ext(ZigTarget *target);75const char *target_o_file_ext(ZigTarget *target);
7676
src/tokenizer.cpp+16-16
...@@ -309,7 +309,7 @@ static void end_float_token(Tokenize *t) {...@@ -309,7 +309,7 @@ static void end_float_token(Tokenize *t) {
309 if (t->is_exp_negative) {309 if (t->is_exp_negative) {
310 specified_exponent = -specified_exponent;310 specified_exponent = -specified_exponent;
311 }311 }
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
314 uint64_t significand = t->cur_tok->data.num_lit.bignum.data.x_uint;314 uint64_t significand = t->cur_tok->data.num_lit.bignum.data.x_uint;
315 uint64_t significand_bits;315 uint64_t significand_bits;
...@@ -352,7 +352,7 @@ static void end_token(Tokenize *t) {...@@ -352,7 +352,7 @@ static void end_token(Tokenize *t) {
352 }352 }
353 } else if (t->cur_tok->id == TokenIdSymbol) {353 } else if (t->cur_tok->id == TokenIdSymbol) {
354 char *token_mem = buf_ptr(t->buf) + t->cur_tok->start_pos;354 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
357 for (size_t i = 0; i < array_length(zig_keywords); i += 1) {357 for (size_t i = 0; i < array_length(zig_keywords); i += 1) {
358 if (mem_eql_str(token_mem, token_len, zig_keywords[i].text)) {358 if (mem_eql_str(token_mem, token_len, zig_keywords[i].text)) {
...@@ -1088,39 +1088,39 @@ void tokenize(Buf *buf, Tokenization *out) {...@@ -1088,39 +1088,39 @@ void tokenize(Buf *buf, Tokenization *out) {
1088 if (t.unicode) {1088 if (t.unicode) {
1089 if (t.char_code <= 0x7f) {1089 if (t.char_code <= 0x7f) {
1090 // 00000000 00000000 00000000 0xxxxxxx1090 // 00000000 00000000 00000000 0xxxxxxx
1091 handle_string_escape(&t, t.char_code);1091 handle_string_escape(&t, (uint8_t)t.char_code);
1092 } else if (t.cur_tok->id == TokenIdCharLiteral) {1092 } else if (t.cur_tok->id == TokenIdCharLiteral) {
1093 tokenize_error(&t, "unicode value too large for character literal: %x", t.char_code);1093 tokenize_error(&t, "unicode value too large for character literal: %x", t.char_code);
1094 } else if (t.char_code <= 0x7ff) {1094 } else if (t.char_code <= 0x7ff) {
1095 // 00000000 00000000 00000xxx xx0000001095 // 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)));
1097 // 00000000 00000000 00000000 00xxxxxx1097 // 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)));
1099 } else if (t.char_code <= 0xffff) {1099 } else if (t.char_code <= 0xffff) {
1100 // 00000000 00000000 xxxx0000 000000001100 // 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)));
1102 // 00000000 00000000 0000xxxx xx0000001102 // 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)));
1104 // 00000000 00000000 00000000 00xxxxxx1104 // 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)));
1106 } else if (t.char_code <= 0x10ffff) {1106 } else if (t.char_code <= 0x10ffff) {
1107 // 00000000 000xxx00 00000000 000000001107 // 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)));
1109 // 00000000 000000xx xxxx0000 000000001109 // 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)));
1111 // 00000000 00000000 0000xxxx xx0000001111 // 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)));
1113 // 00000000 00000000 00000000 00xxxxxx1113 // 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)));
1115 } else {1115 } else {
1116 tokenize_error(&t, "unicode value out of range: %x", t.char_code);1116 tokenize_error(&t, "unicode value out of range: %x", t.char_code);
1117 }1117 }
1118 } else {1118 } 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) {
1120 tokenize_error(&t, "value too large for character literal: '%x'",1120 tokenize_error(&t, "value too large for character literal: '%x'",
1121 t.char_code);1121 t.char_code);
1122 }1122 }
1123 handle_string_escape(&t, t.char_code);1123 handle_string_escape(&t, (uint8_t)t.char_code);
1124 }1124 }
1125 }1125 }
1126 }1126 }
...@@ -1396,8 +1396,8 @@ void tokenize(Buf *buf, Tokenization *out) {...@@ -1396,8 +1396,8 @@ void tokenize(Buf *buf, Tokenization *out) {
1396 if (t.state != TokenizeStateError) {1396 if (t.state != TokenizeStateError) {
1397 if (t.tokens->length > 0) {1397 if (t.tokens->length > 0) {
1398 Token *last_token = &t.tokens->last();1398 Token *last_token = &t.tokens->last();
1399 t.line = last_token->start_line;1399 t.line = (int)last_token->start_line;
1400 t.column = last_token->start_column;1400 t.column = (int)last_token->start_column;
1401 t.pos = last_token->start_pos;1401 t.pos = last_token->start_pos;
1402 } else {1402 } else {
1403 t.pos = 0;1403 t.pos = 0;
src/util.cpp+1-1
...@@ -36,7 +36,7 @@ bool uint64_eq(uint64_t a, uint64_t b) {...@@ -36,7 +36,7 @@ bool uint64_eq(uint64_t a, uint64_t b) {
36}36}
3737
38uint32_t ptr_hash(const void *ptr) {38uint32_t ptr_hash(const void *ptr) {
39 return ((uintptr_t)ptr) % UINT32_MAX;39 return (uint32_t)(((uintptr_t)ptr) % UINT32_MAX);
40}40}
4141
42bool ptr_eq(const void *a, const void *b) {42bool ptr_eq(const void *a, const void *b) {