From dfb80ded6767f7b79a0f1fa4f6921d543ff0a643 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Sat, 18 Feb 2012 20:53:32 +0000 Subject: Fix wrong-code bug: __imag on a scalar lvalue should produce a zero rvalue, rather than an lvalue referring to the scalar. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150889 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGExprScalar.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/CodeGen/CGExprScalar.cpp') diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp index 8bd4c2b5aa..6eed2ed346 100644 --- a/lib/CodeGen/CGExprScalar.cpp +++ b/lib/CodeGen/CGExprScalar.cpp @@ -1642,7 +1642,10 @@ Value *ScalarExprEmitter::VisitUnaryImag(const UnaryOperator *E) { // __imag on a scalar returns zero. Emit the subexpr to ensure side // effects are evaluated, but not the actual value. - CGF.EmitScalarExpr(Op, true); + if (Op->isGLValue()) + CGF.EmitLValue(Op); + else + CGF.EmitScalarExpr(Op, true); return llvm::Constant::getNullValue(ConvertType(E->getType())); } -- cgit v1.2.3