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/CGExpr.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lib/CodeGen/CGExpr.cpp') diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index 3871f33a26..060841d507 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -1465,9 +1465,10 @@ LValue CodeGenFunction::EmitUnaryOpLValue(const UnaryOperator *E) { assert(LV.isSimple() && "real/imag on non-ordinary l-value"); llvm::Value *Addr = LV.getAddress(); - // real and imag are valid on scalars. This is a faster way of - // testing that. - if (!cast(Addr->getType()) + // __real is valid on scalars. This is a faster way of testing that. + // __imag can only produce an rvalue on scalars. + if (E->getOpcode() == UO_Real && + !cast(Addr->getType()) ->getElementType()->isStructTy()) { assert(E->getSubExpr()->getType()->isArithmeticType()); return LV; -- cgit v1.2.3