diff --git a/driver/ldmd.cpp b/driver/ldmd.cpp index 0b731ed2..fb931854 100644 --- a/driver/ldmd.cpp +++ b/driver/ldmd.cpp @@ -682,7 +682,7 @@ Params parseArgs(int originalArgc, char** originalArgv, ls::Path ldcPath) else if (strcmp(p + 1, "run") == 0) { result.run = true; - int runargCount = ((i >= originalArgc) ? argc : originalArgc) - i - 1; + int runargCount = (((int)i >= originalArgc) ? argc : originalArgc) - i - 1; if (runargCount) { result.files.push_back(argv[i + 1]); diff --git a/driver/linker.cpp b/driver/linker.cpp index 71e068a6..0c8438a5 100644 --- a/driver/linker.cpp +++ b/driver/linker.cpp @@ -83,7 +83,7 @@ static int ExecuteToolAndWait(llvm::sys::Path tool, std::vector arg if (verbose) { // Print it - for (int i = 0; i < realargs.size()-1; i++) + for (size_t i = 0; i < realargs.size()-1; i++) printf("%s ", realargs[i]); printf("\n"); fflush(stdout); diff --git a/driver/main.cpp b/driver/main.cpp index 9ca421ef..0321fff6 100644 --- a/driver/main.cpp +++ b/driver/main.cpp @@ -1138,7 +1138,7 @@ int main(int argc, char** argv) llvm::Linker linker("ldc", moduleName, context); std::string errormsg; - for (int i = 0; i < llvmModules.size(); i++) + for (size_t i = 0; i < llvmModules.size(); i++) { if(linker.LinkInModule(llvmModules[i], &errormsg)) error("%s", errormsg.c_str()); diff --git a/gen/asmstmt.cpp b/gen/asmstmt.cpp index 94882caa..168897ed 100644 --- a/gen/asmstmt.cpp +++ b/gen/asmstmt.cpp @@ -319,7 +319,7 @@ assert(0 && "asm fixme Arg_LocalSize"); // FIXME // if (! irs->func->naked) { assert(asmparser); - for (int i = 0; i < code->regs.size(); i++) { + for (size_t i = 0; i < code->regs.size(); i++) { if (code->regs[i]) { clobbers.push_back(asmparser->getRegName(i)); } diff --git a/gen/classes.cpp b/gen/classes.cpp index f06ee792..4141da1c 100644 --- a/gen/classes.cpp +++ b/gen/classes.cpp @@ -307,7 +307,7 @@ DValue* DtoCastClass(DValue* val, Type* _to) // find interface impl size_t i_index = typeclass->getInterfaceIndex(it); - assert(i_index != ~0 && "requesting interface that is not implemented by this class"); + assert(i_index != ~0UL && "requesting interface that is not implemented by this class"); // offset pointer LLValue* v = val->getRVal(); diff --git a/gen/declarations.cpp b/gen/declarations.cpp index b7d08ff0..7a5aed3c 100644 --- a/gen/declarations.cpp +++ b/gen/declarations.cpp @@ -182,9 +182,8 @@ void VarDeclaration::codegen(Ir* p) // Set the alignment (it is important not to use type->alignsize because // VarDeclarations can have an align() attribute independent of the type - // as well). FIXME: ~0 is really STRUCTALIGN_DEFAULT, change as soon as - // 1.075 has been merged. - if (alignment != ~0) + // as well). + if (alignment != STRUCTALIGN_DEFAULT) gvar->setAlignment(alignment); if (Logger::enabled()) diff --git a/gen/functions.cpp b/gen/functions.cpp index 0e89c4ad..2091559f 100644 --- a/gen/functions.cpp +++ b/gen/functions.cpp @@ -565,7 +565,7 @@ static void set_param_attrs(TypeFunction* f, llvm::Function* func, FuncDeclarati } // build rest of attrs list - for (int i = 0; i < n; i++) + for (size_t i = 0; i < n; i++) { if (HAS_ATTRIBUTES(attrptr[i])) { @@ -789,7 +789,7 @@ void DtoDeclareFunction(FuncDeclaration* fdecl) ++iarg; } - int k = 0; + unsigned int k = 0; for (; iarg != func->arg_end(); ++iarg) { @@ -940,7 +940,7 @@ void DtoDefineFunction(FuncDeclaration* fd) { size_t n = f->fty.args.size(); assert(n == fd->parameters->dim); - for (int i=0; i < n; ++i) + for (size_t i=0; i < n; ++i) { Dsymbol* argsym = static_cast(fd->parameters->data[i]); VarDeclaration* vd = argsym->isVarDeclaration(); diff --git a/gen/statements.cpp b/gen/statements.cpp index 39fb2b5c..99ee6d29 100644 --- a/gen/statements.cpp +++ b/gen/statements.cpp @@ -1113,7 +1113,7 @@ void UnrolledLoopStatement::toIR(IRState* p) // do statements Statement** stmts = (Statement**)statements->data; - for (int i=0; i& args, size_t n_arguments = arguments ? arguments->dim : 0; // build struct with argument types (non variadic args) - for (int i=begin; i(arguments->data[i]); assert(argexp->type->ty != Ttuple); @@ -257,7 +257,7 @@ void DtoBuildDVarArgList(std::vector& args, LLValue* mem = DtoRawAlloca(vtype, 0, "_argptr_storage"); // store arguments in the struct - for (int i=begin,k=0; i(arguments->data[i]); LLValue* argdst = DtoGEPi(mem,0,k); @@ -275,7 +275,7 @@ void DtoBuildDVarArgList(std::vector& args, Logger::cout() << "_arguments storage: " << *typeinfomem << '\n'; std::vector vtypeinfos; - for (int i=begin,k=0; i(arguments->data[i]); vtypeinfos.push_back(DtoTypeInfoOf(argexp->type)); @@ -491,7 +491,7 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions* // variadic intrinsics need some custom casts if (va_intrinsic) { - for (int i=0; i(arguments->data[i]); DValue* expelem = exp->toElem(gIR); @@ -540,7 +540,7 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions* argvals.insert(argvals.begin(), argval); } } else { - for (int i=0; iparameters, i); assert(fnarg); DValue* argval = DtoArgument(fnarg, static_cast(arguments->data[i])); @@ -550,7 +550,7 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions* // do formal params int beg = argiter-argbegin; - for (int i=0; i n) { - for (int i=n; iparameters, i); DValue* argval = DtoArgument(fnarg, static_cast(arguments->data[i])); diff --git a/gen/toir.cpp b/gen/toir.cpp index c4c8688e..1947627e 100644 --- a/gen/toir.cpp +++ b/gen/toir.cpp @@ -3251,7 +3251,7 @@ DValue* VectorExp::toElem(IRState* p) ArrayLiteralExp *e = static_cast(e1); assert(e->elements->dim == dim && "Array literal vector initializer " "length mismatch, should have been handled in frontend."); - for (int i = 0; i < dim; ++i) { + for (unsigned int i = 0; i < dim; ++i) { DValue *val = ((*e->elements)[i])->toElem(p); LLValue *llval = DtoCast(loc, val, type->elementType())->getRVal(); DtoStore(llval, DtoGEPi(vector, 0, i)); @@ -3260,7 +3260,7 @@ DValue* VectorExp::toElem(IRState* p) Logger::println("normal (splat) expression"); DValue *val = e1->toElem(p); LLValue* llval = DtoCast(loc, val, type->elementType())->getRVal(); - for (int i = 0; i < dim; ++i) { + for (unsigned int i = 0; i < dim; ++i) { DtoStore(llval, DtoGEPi(vector, 0, i)); } } diff --git a/ir/irfuncty.cpp b/ir/irfuncty.cpp index 40b0749b..c1d6c8c6 100644 --- a/ir/irfuncty.cpp +++ b/ir/irfuncty.cpp @@ -57,9 +57,9 @@ llvm::Value* IrFuncTy::getRet(Type* dty, DValue* val) return val->getRVal(); } -llvm::Value* IrFuncTy::putParam(Type* dty, int idx, DValue* val) +llvm::Value* IrFuncTy::putParam(Type* dty, size_t idx, DValue* val) { - assert(idx >= 0 && idx < args.size() && "invalid putParam"); + assert(idx < args.size() && "invalid putParam"); if (args[idx]->rewrite) { Logger::println("Rewrite: putParam"); LOG_SCOPE @@ -68,9 +68,9 @@ llvm::Value* IrFuncTy::putParam(Type* dty, int idx, DValue* val) return val->getRVal(); } -llvm::Value* IrFuncTy::getParam(Type* dty, int idx, DValue* val) +llvm::Value* IrFuncTy::getParam(Type* dty, size_t idx, DValue* val) { - assert(idx >= 0 && idx < args.size() && "invalid getParam"); + assert(idx < args.size() && "invalid getParam"); if (args[idx]->rewrite) { Logger::println("Rewrite: getParam (get)"); LOG_SCOPE @@ -79,9 +79,9 @@ llvm::Value* IrFuncTy::getParam(Type* dty, int idx, DValue* val) return val->getRVal(); } -void IrFuncTy::getParam(Type* dty, int idx, DValue* val, llvm::Value* lval) +void IrFuncTy::getParam(Type* dty, size_t idx, DValue* val, llvm::Value* lval) { - assert(idx >= 0 && idx < args.size() && "invalid getParam"); + assert(idx < args.size() && "invalid getParam"); if (args[idx]->rewrite) { diff --git a/ir/irfuncty.h b/ir/irfuncty.h index 2b00d7be..e56b21c9 100644 --- a/ir/irfuncty.h +++ b/ir/irfuncty.h @@ -157,9 +157,9 @@ struct IrFuncTy : IrBase llvm::Value* putRet(Type* dty, DValue* dval); llvm::Value* getRet(Type* dty, DValue* dval); - llvm::Value* putParam(Type* dty, int idx, DValue* dval); - llvm::Value* getParam(Type* dty, int idx, DValue* dval); - void getParam(Type* dty, int idx, DValue* dval, llvm::Value* lval); + llvm::Value* putParam(Type* dty, size_t idx, DValue* dval); + llvm::Value* getParam(Type* dty, size_t idx, DValue* dval); + void getParam(Type* dty, size_t idx, DValue* dval, llvm::Value* lval); }; #endif diff --git a/ir/irtypeclass.cpp b/ir/irtypeclass.cpp index db3cf1ae..943b2b2c 100644 --- a/ir/irtypeclass.cpp +++ b/ir/irtypeclass.cpp @@ -324,7 +324,7 @@ std::vector IrTypeClass::buildVtblType(Type* first, Array* vtbl_arr { Logger::println("Running late semantic3 to infer return type."); TemplateInstance *spec = fd->isSpeculative(); - int olderrs = global.errors; + unsigned int olderrs = global.errors; fd->semantic3(fd->scope); if (spec && global.errors != olderrs) spec->errors = global.errors - olderrs; @@ -360,7 +360,7 @@ size_t IrTypeClass::getInterfaceIndex(ClassDeclaration * inter) { ClassIndexMap::iterator it = interfaceMap.find(inter); if (it == interfaceMap.end()) - return ~0; + return ~0UL; return it->second; } diff --git a/utils/gen_gccbuiltins.cpp b/utils/gen_gccbuiltins.cpp index b92d9585..679c1854 100644 --- a/utils/gen_gccbuiltins.cpp +++ b/utils/gen_gccbuiltins.cpp @@ -100,7 +100,7 @@ void processRecord(raw_ostream& os, Record& rec, string arch) ListInit* paramsList = rec.getValueAsListInit("ParamTypes"); vector params; - for(int i = 0; i < paramsList->getSize(); i++) + for(unsigned int i = 0; i < paramsList->getSize(); i++) { string t = dtype(paramsList->getElementAsRecord(i)); if(t == "") @@ -128,7 +128,7 @@ void processRecord(raw_ostream& os, Record& rec, string arch) if(params.size()) os << params[0]; - for(int i = 1; i < params.size(); i++) + for(size_t i = 1; i < params.size(); i++) os << ", " << params[i]; os << ")" + attributes(rec.getValueAsListInit("Properties")) + ";\n\n";