From: Richard Smith Date: Fri, 28 Oct 2011 23:26:52 +0000 (+0000) Subject: Fix assertion in constant expression evaluation. The LHS of a floating-point X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ee591a90c2e26c1ba33a4befb364a1c35fb2c311;p=clang Fix assertion in constant expression evaluation. The LHS of a floating-point 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 --- diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index 89bcacf2bb..6e2e15c6cb 100644 --- a/lib/AST/ExprConstant.cpp +++ b/lib/AST/ExprConstant.cpp @@ -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 diff --git a/test/Sema/const-eval.c b/test/Sema/const-eval.c index bdb40ae54b..6dcc6db765 100644 --- a/test/Sema/const-eval.c +++ b/test/Sema/const-eval.c @@ -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}}