summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-01-24 19:08:01 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-01-24 19:08:01 +0000
commit134a02586e25f60811096c038492f4c8e17917da (patch)
treec99e077c42c6e6bc6799049137b93c9cb3536c27 /clang/lib
parenta0b892113a9977575b3ca647339225c0302cfeee (diff)
downloadbcm5719-llvm-134a02586e25f60811096c038492f4c8e17917da.tar.gz
bcm5719-llvm-134a02586e25f60811096c038492f4c8e17917da.zip
Fix invalid evaluation of _Complex float (real & imaginary parts had
mismatched semantics). - Enforce this in APValue. llvm-svn: 62924
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/AST/ExprConstant.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index f45bd787b56..16c6e89c329 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -1194,7 +1194,8 @@ public:
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) {
@@ -1206,7 +1207,8 @@ public:
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.
@@ -1221,6 +1223,10 @@ public:
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();
}
OpenPOWER on IntegriCloud