Permalink
Browse files

quench MSVC32 warnings

  • Loading branch information...
1 parent 5575b9c commit 24961e12e542be7eba8a27b3bf4bd3b52fa09c57 @jckarter committed Apr 14, 2012
Showing with 44 additions and 35 deletions.
  1. +7 −3 compiler/src/analyzer.cpp
  2. +20 −17 compiler/src/codegen.cpp
  3. +1 −1 compiler/src/desugar.cpp
  4. +15 −13 compiler/src/evaluator.cpp
  5. +1 −1 compiler/src/printer.cpp
View
@@ -1637,10 +1637,14 @@ MultiPValuePtr analyzeDispatch(ObjectPtr obj,
for (unsigned i = index+1; i < args->size(); ++i)
suffix->add(args->values[i]);
PVData const &pvDispatch = args->values[index];
- int memberCount = dispatchTagCount(pvDispatch.type);
+ int iMemberCount = dispatchTagCount(pvDispatch.type);
+ if (iMemberCount <= 0)
+ argumentError(index, "DispatchMemberCount for type must be positive");
+ size_t memberCount = (size_t)iMemberCount;
+
MultiPValuePtr result;
vector<TypePtr> dispatchedTypes;
- for (unsigned i = 0; i < memberCount; ++i) {
+ for (size_t i = 0; i < memberCount; ++i) {
MultiPValuePtr args2 = new MultiPValue();
args2->add(prefix);
PVData pvDispatch2 = analyzeDispatchIndex(pvDispatch, i);
@@ -2825,7 +2829,7 @@ MultiPValuePtr analyzePrimOp(PrimOpPtr x, MultiPValuePtr args)
}
else if (vh->type == cSizeTType) {
size_t count = *((size_t *)vh->buf);
- for (int i = 0; i < count; ++i)
+ for (size_t i = 0; i < count; ++i)
mpv->add(PVData(cSizeTType, true));
}
else {
View
@@ -2158,22 +2158,23 @@ void codegenDispatch(ObjectPtr obj,
CValuePtr cvDispatch = args->values[index];
PVData const &pvDispatch = pvArgs->values[index];
- int memberCount = dispatchTagCount(pvDispatch.type);
- if (memberCount <= 0)
+ int iMemberCount = dispatchTagCount(pvDispatch.type);
+ if (iMemberCount <= 0)
argumentError(index, "DispatchMemberCount for type must be positive");
+ size_t memberCount = (size_t)iMemberCount;
llvm::Value *llTag = codegenDispatchTag(cvDispatch, ctx);
vector<llvm::BasicBlock *> callBlocks;
vector<llvm::BasicBlock *> elseBlocks;
- for (unsigned i = 0; i < memberCount; ++i) {
+ for (size_t i = 0; i < memberCount; ++i) {
callBlocks.push_back(newBasicBlock("dispatchCase", ctx));
elseBlocks.push_back(newBasicBlock("dispatchNext", ctx));
}
llvm::BasicBlock *finalBlock = newBasicBlock("finalBlock", ctx);
- for (unsigned i = 0; i < memberCount; ++i) {
+ for (size_t i = 0; i < memberCount; ++i) {
llvm::Value *tagCase = llvm::ConstantInt::get(llvmIntType(32), i);
llvm::Value *cond = ctx->builder->CreateICmpEQ(llTag, tagCase);
ctx->builder->CreateCondBr(cond, callBlocks[i], elseBlocks[i]);
@@ -4867,17 +4868,19 @@ void codegenPrimOp(PrimOpPtr x,
case PRIM_SymbolP : {
ensureArity(args, 1);
ObjectPtr obj = valueToStatic(args->values[0]);
- bool isSymbol;
- switch (obj->objKind) {
- case TYPE :
- case RECORD :
- case VARIANT :
- case PROCEDURE :
- case GLOBAL_ALIAS:
- isSymbol = obj.ptr();
- break;
- default :
- isSymbol = false;
+ bool isSymbol = false;
+ if (obj.ptr() != NULL) {
+ switch (obj->objKind) {
+ case TYPE :
+ case RECORD :
+ case VARIANT :
+ case PROCEDURE :
+ case GLOBAL_ALIAS:
+ isSymbol = true;
+ break;
+ default :
+ break;
+ }
}
ValueHolderPtr vh = boolToValueHolder(isSymbol);
codegenStaticObject(vh.ptr(), ctx, out);
@@ -5524,7 +5527,7 @@ void codegenPrimOp(PrimOpPtr x,
llvm::Value *v0 = pointerValue(args, 0, t, ctx);
IntegerTypePtr offsetT;
llvm::Value *v1 = integerValue(args, 1, offsetT, ctx);
- if (!offsetT->isSigned && offsetT->bits < typeSize(cSizeTType)*8)
+ if (!offsetT->isSigned && (size_t)offsetT->bits < typeSize(cSizeTType)*8)
v1 = ctx->builder->CreateZExt(v1, llvmType(cSizeTType));
vector<llvm::Value *> indices;
indices.push_back(v1);
@@ -5755,7 +5758,7 @@ void codegenPrimOp(PrimOpPtr x,
llvm::Value *av = arrayValue(args, 0, at);
IntegerTypePtr indexType;
llvm::Value *iv = integerValue(args, 1, indexType, ctx);
- if (!indexType->isSigned && indexType->bits < typeSize(cSizeTType)*8)
+ if (!indexType->isSigned && (size_t)indexType->bits < typeSize(cSizeTType)*8)
iv = ctx->builder->CreateZExt(iv, llvmType(cSizeTType));
vector<llvm::Value *> indices;
indices.push_back(llvm::ConstantInt::get(llvmIntType(32), 0));
View
@@ -360,7 +360,7 @@ static StatementPtr desugarWithBlock(WithStatementPtr with,
}
vector<FormalArgPtr> formalArgs;
- for(int i = 0; i < with->lhs.size(); i++) {
+ for(size_t i = 0; i < with->lhs.size(); i++) {
formalArgs.push_back(new FormalArg(with->lhs.at(i), NULL, TEMPNESS_DONTCARE));
}
View
@@ -2491,8 +2491,8 @@ size_t valueHolderToSizeT(ValueHolderPtr vh)
{
switch (typeSize(cSizeTType)) {
case 4 : return vh->as<size32_t>();
- case 8 : return vh->as<size64_t>();
- default : assert(false);
+ case 8 : return (size_t)vh->as<size64_t>();
+ default : llvm_unreachable("unexpected pointer size");
}
}
@@ -3552,17 +3552,19 @@ void evalPrimOp(PrimOpPtr x, MultiEValuePtr args, MultiEValuePtr out)
case PRIM_SymbolP : {
ensureArity(args, 1);
ObjectPtr obj = valueToStatic(args->values[0]);
- bool isSymbol;
- switch (obj->objKind) {
- case TYPE :
- case RECORD :
- case VARIANT :
- case PROCEDURE :
- case GLOBAL_ALIAS:
- isSymbol = obj.ptr();
- break;
- default :
- isSymbol = false;
+ bool isSymbol = false;
+ if (obj.ptr() != NULL) {
+ switch (obj->objKind) {
+ case TYPE :
+ case RECORD :
+ case VARIANT :
+ case PROCEDURE :
+ case GLOBAL_ALIAS:
+ isSymbol = true;
+ break;
+ default :
+ break;
+ }
}
assert(out->size() == 1);
EValuePtr out0 = out->values[0];
View
@@ -315,7 +315,7 @@ static void printExpr(llvm::raw_ostream &out, const Expr *x) {
static void printStatement(llvm::raw_ostream &out, const Statement *x) {
switch (x->stmtKind) {
case WITH : {
- const WithStatement *y = (const WithStatement *)y;
+ const WithStatement *y = (const WithStatement *)x;
out << "WithStatement(" << y->lhs << ", " << y->rhs << ")";
break;
}

0 comments on commit 24961e1

Please sign in to comment.