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 | 390cd49906822e2d2aa6d68f58b9fc5620e725a0 (patch) | |
| tree | 50d9fd18baab9671098ecd666a47a6ead57fa83a | |
| parent | 228d9131aad9f3553c9c69abf010f41ce43c8423 (diff) | |
| download | bcm5719-llvm-390cd49906822e2d2aa6d68f58b9fc5620e725a0.tar.gz bcm5719-llvm-390cd49906822e2d2aa6d68f58b9fc5620e725a0.zip | |
Fix assert on constant expression evaluation of floating point increment.
llvm-svn: 143320
| -rw-r--r-- | clang/lib/AST/ExprConstant.cpp | 10 | ||||
| -rw-r--r-- | clang/test/Sema/const-eval.c | 1 |
2 files changed, 4 insertions, 7 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index f33827ff7c4..bf428aaacc4 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/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/clang/test/Sema/const-eval.c b/clang/test/Sema/const-eval.c index ee55ca871fe..8cfa7ea6f87 100644 --- a/clang/test/Sema/const-eval.c +++ b/clang/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}} |

