((Vec*)(void*)Data)->Elts[i] = E[i];
}
void setComplexInt(const APSInt &R, const APSInt &I) {
+ assert(R.getBitWidth() == I.getBitWidth() &&
+ "Invalid complex int (type mismatch).");
assert(isComplexInt() && "Invalid accessor");
((ComplexAPSInt*)(void*)Data)->Real = R;
((ComplexAPSInt*)(void*)Data)->Imag = I;
}
void setComplexFloat(const APFloat &R, const APFloat &I) {
+ assert(&R.getSemantics() == &I.getSemantics() &&
+ "Invalid complex float (type mismatch).");
assert(isComplexFloat() && "Invalid accessor");
((ComplexAPFloat*)(void*)Data)->Real = R;
((ComplexAPFloat*)(void*)Data)->Imag = I;
if (!EvaluateFloat(E->getSubExpr(), Result, Info))
return APValue();
- return APValue(APFloat(0.0), Result);
+ return APValue(APFloat(Result.getSemantics(), APFloat::fcZero),
+ Result);
}
APValue VisitCastExpr(CastExpr *E) {
if (!EvaluateFloat(SubExpr, Result, Info))
return APValue();
- return APValue(Result, APFloat(0.0));
+ return APValue(Result,
+ APFloat(Result.getSemantics(), APFloat::fcZero));
}
// FIXME: Handle more casts.
static bool EvaluateComplexFloat(const Expr *E, APValue &Result, EvalInfo &Info)
{
Result = ComplexFloatExprEvaluator(Info).Visit(const_cast<Expr*>(E));
+ if (Result.isComplexFloat())
+ assert(&Result.getComplexFloatReal().getSemantics() ==
+ &Result.getComplexFloatImag().getSemantics() &&
+ "Invalid complex evaluation.");
return Result.isComplexFloat();
}
int a;
EVAL_EXPR(15, (_Bool)&a); // expected-error {{fields must have a constant size}}
}
+
+// FIXME: Turn into EVAL_EXPR test once we have more folding.
+_Complex float g16 = (1.0f + 1.0fi);