diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2009-11-16 04:25:37 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2009-11-16 04:25:37 +0000 |
commit | 141fbf3f367b197c4d9a06d9a0d3181a0f81b81b (patch) | |
tree | 4f67874ed58fe034bb32d1d9d279e43b17a6f5f2 /clang/lib/AST/ExprConstant.cpp | |
parent | e58c05780e5afea17ecd3ea5da11377f92f86eb9 (diff) | |
download | bcm5719-llvm-141fbf3f367b197c4d9a06d9a0d3181a0f81b81b.tar.gz bcm5719-llvm-141fbf3f367b197c4d9a06d9a0d3181a0f81b81b.zip |
Add constant evaluation for comma operator with floating-point operand. Fixes
PR5449.
llvm-svn: 88885
Diffstat (limited to 'clang/lib/AST/ExprConstant.cpp')
-rw-r--r-- | clang/lib/AST/ExprConstant.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index c036640b711..2689859e8e4 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -1488,7 +1488,7 @@ public: // FIXME: Missing: __real__/__imag__, array subscript of vector, // member of vector, ImplicitValueInitExpr, - // conditional ?:, comma + // conditional ?: }; } // end anonymous namespace @@ -1577,6 +1577,18 @@ bool FloatExprEvaluator::VisitUnaryOperator(const UnaryOperator *E) { } bool FloatExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) { + if (E->getOpcode() == BinaryOperator::Comma) { + if (!EvaluateFloat(E->getRHS(), Result, Info)) + return false; + + // If we can't evaluate the LHS, it might have side effects; + // conservatively mark it. + if (!E->getLHS()->isEvaluatable(Info.Ctx)) + Info.EvalResult.HasSideEffects = true; + + return true; + } + // FIXME: Diagnostics? I really don't understand how the warnings // and errors are supposed to work. APFloat RHS(0.0); |