[cfe-commits] r143320 - in /cfe/trunk: lib/AST/ExprConstant.cpp test/Sema/const-eval.c
Richard Smith
richard-llvm at metafoo.co.uk
Sun Oct 30 16:17:09 PDT 2011
Author: rsmith
Date: Sun Oct 30 18:17:09 2011
New Revision: 143320
URL: http://llvm.org/viewvc/llvm-project?rev=143320&view=rev
Log:
Fix assert on constant expression evaluation of floating point increment.
Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/Sema/const-eval.c
Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=143320&r1=143319&r2=143320&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Sun Oct 30 18:17:09 2011
@@ -2529,17 +2529,13 @@
}
bool FloatExprEvaluator::VisitUnaryOperator(const UnaryOperator *E) {
- if (E->getOpcode() == UO_Deref)
- return false;
-
- if (!EvaluateFloat(E->getSubExpr(), Result, Info))
- return false;
-
switch (E->getOpcode()) {
default: return false;
case UO_Plus:
- return true;
+ return EvaluateFloat(E->getSubExpr(), Result, Info);
case UO_Minus:
+ if (!EvaluateFloat(E->getSubExpr(), Result, Info))
+ return false;
Result.changeSign();
return true;
}
Modified: cfe/trunk/test/Sema/const-eval.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/const-eval.c?rev=143320&r1=143319&r2=143320&view=diff
==============================================================================
--- cfe/trunk/test/Sema/const-eval.c (original)
+++ cfe/trunk/test/Sema/const-eval.c Sun Oct 30 18:17:09 2011
@@ -88,6 +88,7 @@
}
double d = (d = 0.0); // expected-error {{not a compile-time constant}}
+double d2 = ++d; // expected-error {{not a compile-time constant}}
int n = 2;
int intLvalue[*(int*)((long)&n ?: 1)] = { 1, 2 }; // expected-error {{variable length array}}
More information about the cfe-commits
mailing list