]> granicus.if.org Git - clang/commitdiff
Fix assertion in constant expression evaluation. The LHS of a floating-point
authorRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 28 Oct 2011 23:26:52 +0000 (23:26 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 28 Oct 2011 23:26:52 +0000 (23:26 +0000)
binary operator isn't an rvalue if it's an assignment operator.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143250 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 89bcacf2bba815ad0b3b2b5385ed34ea4608b08a..6e2e15c6cb6bea51e525d20e20173aa01b907a0a 100644 (file)
@@ -2492,8 +2492,8 @@ bool FloatExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
     return Visit(E->getRHS());
   }
 
-  // We can't evaluate pointer-to-member operations.
-  if (E->isPtrMemOp())
+  // We can't evaluate pointer-to-member operations or assignments.
+  if (E->isPtrMemOp() || E->isAssignmentOp())
     return false;
 
   // FIXME: Diagnostics?  I really don't understand how the warnings
index bdb40ae54be3bc3e5d6e13d3a230bccf78a36589..6dcc6db7659645ea3a679e6ba23105f2a754f9ef 100644 (file)
@@ -86,3 +86,5 @@ void rdar8875946() {
   double _Complex  P;
   float _Complex  P2 = 3.3f + P;
 }
+
+double d = (d = 0.0); // expected-error {{not a compile-time constant}}