The FP constant evaluator was missing a few cases of unary operators that return floats

but whose operand isn't a float:  specifically, __real__ and __imag__.  Instead
of filtering these out, just implement them.

Fixes <rdar://problem/7958272>.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103307 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
John McCall 2010-05-07 22:08:54 +00:00
Родитель 6ad9ac0979
Коммит abd3a857ac
2 изменённых файлов: 24 добавлений и 2 удалений

Просмотреть файл

@ -1703,9 +1703,11 @@ public:
{ return Visit(E->getChosenSubExpr(Info.Ctx)); }
bool VisitUnaryExtension(const UnaryOperator *E)
{ return Visit(E->getSubExpr()); }
bool VisitUnaryReal(const UnaryOperator *E);
bool VisitUnaryImag(const UnaryOperator *E);
// FIXME: Missing: __real__/__imag__, array subscript of vector,
// member of vector, ImplicitValueInitExpr
// FIXME: Missing: array subscript of vector, member of vector,
// ImplicitValueInitExpr
};
} // end anonymous namespace
@ -1791,6 +1793,22 @@ bool FloatExprEvaluator::VisitCallExpr(const CallExpr *E) {
}
}
bool FloatExprEvaluator::VisitUnaryReal(const UnaryOperator *E) {
ComplexValue CV;
if (!EvaluateComplex(E->getSubExpr(), CV, Info))
return false;
Result = CV.FloatReal;
return true;
}
bool FloatExprEvaluator::VisitUnaryImag(const UnaryOperator *E) {
ComplexValue CV;
if (!EvaluateComplex(E->getSubExpr(), CV, Info))
return false;
Result = CV.FloatImag;
return true;
}
bool FloatExprEvaluator::VisitUnaryOperator(const UnaryOperator *E) {
if (E->getOpcode() == UnaryOperator::Deref)
return false;

Просмотреть файл

@ -89,3 +89,7 @@ void t6() {
--ci1;
}
// <rdar://problem/7958272>
double t7(double _Complex c) {
return __builtin_fabs(__real__(c));
}