Report error when applying int-only ops to float values.
This commit is contained in:
parent
ec21714af9
commit
f9cfe700fa
|
@ -199,7 +199,8 @@ bool BitcodeEmitter::emit(FunctionCall const& node) {
|
||||||
|
|
||||||
if (callee == 0) {
|
if (callee == 0) {
|
||||||
return reportError({
|
return reportError({
|
||||||
"Attempting to call undefined function", node.getName().getValue()
|
"Attempting to call undefined function",
|
||||||
|
node.getName().getValue() + "()"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -419,13 +420,13 @@ bool isFP(llvm::Value const* var) {
|
||||||
|
|
||||||
#define HANDLE_INT_ONLY(op) \
|
#define HANDLE_INT_ONLY(op) \
|
||||||
if (fp) { \
|
if (fp) { \
|
||||||
d->retval = nullptr; \
|
return reportError({"Operator cannot be applied to float values!"}); \
|
||||||
} else { \
|
} else { \
|
||||||
d->retval = d->builder.Create##op(left, right); \
|
d->retval = d->builder.Create##op(left, right); \
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static
|
||||||
void createOp(BitcodeEmitter::Private *d, llvm::Value *left, Operator op, llvm::Value *right) {
|
bool createOp(BitcodeEmitter::Private *d, llvm::Value *left, Operator op, llvm::Value *right) {
|
||||||
bool fp = isFP(left) || isFP(right);
|
bool fp = isFP(left) || isFP(right);
|
||||||
|
|
||||||
// TODO left->getType() != right->getType() Handle automatic casts
|
// TODO left->getType() != right->getType() Handle automatic casts
|
||||||
|
@ -465,6 +466,8 @@ void createOp(BitcodeEmitter::Private *d, llvm::Value *left, Operator op, llvm::
|
||||||
HANDLE(ICmpEQ, FCmpOEQ)
|
HANDLE(ICmpEQ, FCmpOEQ)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef HANDLE
|
#undef HANDLE
|
||||||
|
@ -477,7 +480,7 @@ bool BitcodeEmitter::emit(BinaryExpression const& expression) {
|
||||||
GUARDED(expression.getRight().emit(this));
|
GUARDED(expression.getRight().emit(this));
|
||||||
llvm::Value *right = d->retval;
|
llvm::Value *right = d->retval;
|
||||||
|
|
||||||
createOp(d, left, expression.getOperator(), right);
|
GUARDED(createOp(d, left, expression.getOperator(), right));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -489,7 +492,7 @@ bool BitcodeEmitter::emitSemiExpression(Id const& left, SemiExpression const& ri
|
||||||
GUARDED(right.getLeft().emit(this));
|
GUARDED(right.getLeft().emit(this));
|
||||||
llvm::Value *rhs = d->retval;
|
llvm::Value *rhs = d->retval;
|
||||||
|
|
||||||
createOp(d, lhs, right.getOperator(), rhs);
|
GUARDED(createOp(d, lhs, right.getOperator(), rhs));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue
Block a user