[cfe-commits] r90521 - in /cfe/trunk: lib/AST/ExprConstant.cpp test/Sema/init.c
Eli Friedman
eli.friedman at gmail.com
Thu Dec 3 18:12:53 PST 2009
Author: efriedma
Date: Thu Dec 3 20:12:53 2009
New Revision: 90521
URL: http://llvm.org/viewvc/llvm-project?rev=90521&view=rev
Log:
Fix for PR5447: teach Evaluate to deal with floating-point conditionals.
Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/Sema/init.c
Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=90521&r1=90520&r2=90521&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Thu Dec 3 20:12:53 2009
@@ -1515,6 +1515,7 @@
bool VisitFloatingLiteral(const FloatingLiteral *E);
bool VisitCastExpr(CastExpr *E);
bool VisitCXXZeroInitValueExpr(CXXZeroInitValueExpr *E);
+ bool VisitConditionalOperator(ConditionalOperator *E);
bool VisitChooseExpr(const ChooseExpr *E)
{ return Visit(E->getChosenSubExpr(Info.Ctx)); }
@@ -1522,8 +1523,7 @@
{ return Visit(E->getSubExpr()); }
// FIXME: Missing: __real__/__imag__, array subscript of vector,
- // member of vector, ImplicitValueInitExpr,
- // conditional ?:
+ // member of vector, ImplicitValueInitExpr
};
} // end anonymous namespace
@@ -1682,6 +1682,14 @@
return true;
}
+bool FloatExprEvaluator::VisitConditionalOperator(ConditionalOperator *E) {
+ bool Cond;
+ if (!HandleConversionToBool(E->getCond(), Cond, Info))
+ return false;
+
+ return Visit(Cond ? E->getTrueExpr() : E->getFalseExpr());
+}
+
//===----------------------------------------------------------------------===//
// Complex Evaluation (for float and integer)
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/test/Sema/init.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/init.c?rev=90521&r1=90520&r2=90521&view=diff
==============================================================================
--- cfe/trunk/test/Sema/init.c (original)
+++ cfe/trunk/test/Sema/init.c Thu Dec 3 20:12:53 2009
@@ -126,3 +126,7 @@
// PR4285
const wchar_t widestr[] = L"asdf";
+
+// PR5447
+const double pr5447 = (0.05 < -1.0) ? -1.0 : 0.0499878;
+
More information about the cfe-commits
mailing list