diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-10-30 23:17:09 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-10-30 23:17:09 +0000 |
commit | 7993e8a2a26bf408c2a6d45f24fffa12db336b2b (patch) | |
tree | 17cb994c1366fa085ae0c563bd99e3e7b9f00247 | |
parent | 22a7dfea585703d6755db69b83e29a0e6ee10369 (diff) |
Fix assert on constant expression evaluation of floating point increment.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143320 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/AST/ExprConstant.cpp | 10 | ||||
-rw-r--r-- | test/Sema/const-eval.c | 1 |
2 files changed, 4 insertions, 7 deletions
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index f33827ff7c..bf428aaacc 100644 --- a/lib/AST/ExprConstant.cpp +++ b/lib/AST/ExprConstant.cpp @@ -2529,17 +2529,13 @@ bool FloatExprEvaluator::VisitUnaryImag(const UnaryOperator *E) { } 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; } diff --git a/test/Sema/const-eval.c b/test/Sema/const-eval.c index ee55ca871f..8cfa7ea6f8 100644 --- a/test/Sema/const-eval.c +++ b/test/Sema/const-eval.c @@ -88,6 +88,7 @@ void rdar8875946() { } 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}} |