From 76dc44d2a69293b08d4369dedf5d735e3dc29803 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 12 Jan 2016 21:07:45 -0700 Subject: [PATCH] fix build with gcc closes #66 --- src/analyze.cpp | 9 ++++++--- src/codegen.cpp | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/analyze.cpp b/src/analyze.cpp index 04090d39b6..1526cf4174 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -1503,7 +1503,7 @@ TypeTableEntry *find_container(BlockContext *context, Buf *name) { } static TypeEnumField *get_enum_field(TypeTableEntry *enum_type, Buf *name) { - for (int i = 0; i < enum_type->data.enumeration.field_count; i += 1) { + for (uint32_t i = 0; i < enum_type->data.enumeration.field_count; i += 1) { TypeEnumField *type_enum_field = &enum_type->data.enumeration.fields[i]; if (buf_eql_buf(type_enum_field->name, name)) { return type_enum_field; @@ -1513,7 +1513,7 @@ static TypeEnumField *get_enum_field(TypeTableEntry *enum_type, Buf *name) { } static TypeStructField *get_struct_field(TypeTableEntry *struct_type, Buf *name) { - for (int i = 0; i < struct_type->data.structure.field_count; i += 1) { + for (uint32_t i = 0; i < struct_type->data.structure.field_count; i += 1) { TypeStructField *type_struct_field = &struct_type->data.structure.fields[i]; if (buf_eql_buf(type_struct_field->name, name)) { return type_struct_field; @@ -2111,7 +2111,7 @@ static TypeTableEntry *analyze_number_literal_expr(CodeGen *g, ImportTableEntry static TypeStructField *find_struct_type_field(TypeTableEntry *type_entry, Buf *name, int *index) { assert(type_entry->id == TypeTableEntryIdStruct); - for (int i = 0; i < type_entry->data.structure.field_count; i += 1) { + for (uint32_t i = 0; i < type_entry->data.structure.field_count; i += 1) { TypeStructField *field = &type_entry->data.structure.fields[i]; if (buf_eql_buf(field->name, name)) { *index = i; @@ -3575,6 +3575,7 @@ Expr *get_resolved_expr(AstNode *node) { case NodeTypeStructValueField: zig_unreachable(); } + zig_unreachable(); } NumLitCodeGen *get_resolved_num_lit(AstNode *node) { @@ -3625,6 +3626,7 @@ NumLitCodeGen *get_resolved_num_lit(AstNode *node) { case NodeTypeCompilerFnExpr: zig_unreachable(); } + zig_unreachable(); } TopLevelDecl *get_resolved_top_level_decl(AstNode *node) { @@ -3676,4 +3678,5 @@ TopLevelDecl *get_resolved_top_level_decl(AstNode *node) { case NodeTypeCompilerFnType: zig_unreachable(); } + zig_unreachable(); } diff --git a/src/codegen.cpp b/src/codegen.cpp index cd6d43d661..7fcb58cf50 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -2402,7 +2402,7 @@ static void define_builtin_fns_int(CodeGen *g, TypeTableEntry *type_entry) { {"sub", "ssub", "usub"}, {"mul", "smul", "umul"}, }; - for (int i = 0; i < sizeof(overflow_fns)/sizeof(overflow_fns[0]); i += 1) { + for (size_t i = 0; i < sizeof(overflow_fns)/sizeof(overflow_fns[0]); i += 1) { OverflowFn *overflow_fn = &overflow_fns[i]; BuiltinFnEntry *builtin_fn = allocate(1); buf_resize(&builtin_fn->name, 0);