diff options
author | John McCall <rjmccall@apple.com> | 2011-04-12 22:02:02 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2011-04-12 22:02:02 +0000 |
commit | 6591271275f7a3db357f3cb7af37ef86e800e4ba (patch) | |
tree | 50732610e13030b42681eb38f260dadf701299ad | |
parent | f077c0d4bb1598f9201cdc38592634ca8922da6c (diff) |
We can't emit an aggregate cast as its sub-expression in general just
because the result is ignored. The particular example here is with
property l-values, but there could be all sorts of lovely casts that this
isn't safe for. Sink the check into the one case that seems to actually
be capable of honoring this.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129397 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/CGExprAgg.cpp | 7 | ||||
-rw-r--r-- | test/CodeGenObjC/property-agrr-getter.m | 8 |
2 files changed, 9 insertions, 6 deletions
diff --git a/lib/CodeGen/CGExprAgg.cpp b/lib/CodeGen/CGExprAgg.cpp index 177d0a4be7..4315915c16 100644 --- a/lib/CodeGen/CGExprAgg.cpp +++ b/lib/CodeGen/CGExprAgg.cpp @@ -249,11 +249,6 @@ void AggExprEmitter::VisitOpaqueValueExpr(OpaqueValueExpr *e) { } void AggExprEmitter::VisitCastExpr(CastExpr *E) { - if (Dest.isIgnored() && E->getCastKind() != CK_Dynamic) { - Visit(E->getSubExpr()); - return; - } - switch (E->getCastKind()) { case CK_Dynamic: { assert(isa<CXXDynamicCastExpr>(E) && "CK_Dynamic without a dynamic_cast?"); @@ -270,6 +265,8 @@ void AggExprEmitter::VisitCastExpr(CastExpr *E) { } case CK_ToUnion: { + if (Dest.isIgnored()) break; + // GCC union extension QualType Ty = E->getSubExpr()->getType(); QualType PtrTy = CGF.getContext().getPointerType(Ty); diff --git a/test/CodeGenObjC/property-agrr-getter.m b/test/CodeGenObjC/property-agrr-getter.m index 2dd32bb4f3..6d8f1d6b03 100644 --- a/test/CodeGenObjC/property-agrr-getter.m +++ b/test/CodeGenObjC/property-agrr-getter.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm -o %t %s +// RUN: %clang_cc1 -emit-llvm-only %s typedef struct { unsigned f0; @@ -36,3 +36,9 @@ float f () AnObject* obj; return (obj.size).width; } + +// rdar://problem/9272392 +void test3(AnObject *obj) { + obj.size; + (void) obj.size; +} |