]> granicus.if.org Git - clang/commitdiff
Fix assert on constant expression evaluation of floating point increment.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Sun, 30 Oct 2011 23:17:09 +0000 (23:17 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Sun, 30 Oct 2011 23:17:09 +0000 (23:17 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143320 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ExprConstant.cpp
test/Sema/const-eval.c

index f33827ff7c4eec8b1a148cfd0811c7b0ed06cd92..bf428aaacc41eadf03a640cc992374b58379caad 100644 (file)
@@ -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;
   }
index ee55ca871fea940a3489883eeec8bfc318b7d196..8cfa7ea6f87959ba1fabcccfd61609b839ba276e 100644 (file)
@@ -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}}