diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 89bcacf2bba8..6e2e15c6cb6b 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/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/clang/test/Sema/const-eval.c b/clang/test/Sema/const-eval.c index bdb40ae54be3..6dcc6db76596 100644 --- a/clang/test/Sema/const-eval.c +++ b/clang/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}}