From ab17fb2c985539582ac17540c8db09e138380495 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 18 Mar 2009 18:30:44 +0000 Subject: [PATCH] fix the more complex cases by actually codegen'ing the right expr :) llvm-svn: 67219 --- clang/lib/CodeGen/CGExpr.cpp | 2 +- clang/test/CodeGen/exprs.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 93b2382166ac..95cb53c1f70d 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -1024,7 +1024,7 @@ LValue CodeGenFunction::EmitCastLValue(const CastExpr *E) { // Casts are only lvalues when the source and destination types are the same. llvm::Value *Temp = CreateTempAlloca(ConvertType(E->getType())); - EmitAnyExpr(E, Temp, false); + EmitAnyExpr(E->getSubExpr(), Temp, false); return LValue::MakeAddr(Temp, E->getType().getCVRQualifiers(), getContext().getObjCGCAttrKind(E->getType())); diff --git a/clang/test/CodeGen/exprs.c b/clang/test/CodeGen/exprs.c index a0fe96008952..dbc14997d4e4 100644 --- a/clang/test/CodeGen/exprs.c +++ b/clang/test/CodeGen/exprs.c @@ -82,3 +82,9 @@ unsigned f1(void) { union f3_x {int x; float y;}; int f3() {return ((union f3_x)2).x;} +union f4_y {int x; _Complex float y;}; +_Complex float f4() {return ((union f4_y)(_Complex float)2.0).y;} + +struct f5_a { int a; } f5_a; +union f5_z {int x; struct f5_a y;}; +struct f5_a f5() {return ((union f5_z)f5_a).y;} -- GitLab