From 2ad226bdc847df6b6b6e4f832856478ab63bb3dc Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Wed, 16 Nov 2011 17:22:48 +0000 Subject: [PATCH] PR11391: Don't try to evaluate the LHS of a _Complex assignment as an rvalue. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144799 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/ExprConstant.cpp | 4 ++++ test/Sema/const-eval.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index 699d81715e..f461ec6429 100644 --- a/lib/AST/ExprConstant.cpp +++ b/lib/AST/ExprConstant.cpp @@ -3695,10 +3695,14 @@ bool ComplexExprEvaluator::VisitCastExpr(const CastExpr *E) { } bool ComplexExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) { + if (E->isPtrMemOp() || E->isAssignmentOp()) + return ExprEvaluatorBaseTy::VisitBinaryOperator(E); + if (E->getOpcode() == BO_Comma) { VisitIgnoredValue(E->getLHS()); return Visit(E->getRHS()); } + if (!Visit(E->getLHS())) return false; diff --git a/test/Sema/const-eval.c b/test/Sema/const-eval.c index 094d1ce716..8904e12bf7 100644 --- a/test/Sema/const-eval.c +++ b/test/Sema/const-eval.c @@ -108,3 +108,7 @@ int literalVsNull2 = 0 == "foo"; // PR11385. int castViaInt[*(int*)(unsigned long)"test"]; // expected-error {{variable length array}} + +// PR11391. +struct PR11391 { _Complex float f; } pr11391; +EVAL_EXPR(42, __builtin_constant_p(pr11391.f = 1))