summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGExpr.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-02-18 20:53:32 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-02-18 20:53:32 +0000
commit0b6b8e490c1a81a607bde6e4e92a8a5306c080ce (patch)
treec36575407079ea2d9c35a61b3a74dc0127c5794a /clang/lib/CodeGen/CGExpr.cpp
parente98d63a823f02aa920e9cd4889c303f8e2ad7592 (diff)
downloadbcm5719-llvm-0b6b8e490c1a81a607bde6e4e92a8a5306c080ce.tar.gz
bcm5719-llvm-0b6b8e490c1a81a607bde6e4e92a8a5306c080ce.zip
Fix wrong-code bug: __imag on a scalar lvalue should produce a zero rvalue,
rather than an lvalue referring to the scalar. llvm-svn: 150889
Diffstat (limited to 'clang/lib/CodeGen/CGExpr.cpp')
-rw-r--r--clang/lib/CodeGen/CGExpr.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 3871f33a264..060841d5078 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/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<llvm::PointerType>(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<llvm::PointerType>(Addr->getType())
->getElementType()->isStructTy()) {
assert(E->getSubExpr()->getType()->isArithmeticType());
return LV;
OpenPOWER on IntegriCloud