From: Eli Friedman Date: Sun, 14 Aug 2011 04:50:34 +0000 (+0000) Subject: Fix r137086 to actually work properly in general. PR10650. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ec24b0ed9ccf8b34986eadeb98dd0b4a0a50f6f2;p=clang Fix r137086 to actually work properly in general. PR10650. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137574 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp index 4038be2792..f4a2695ec9 100644 --- a/lib/CodeGen/CGExprScalar.cpp +++ b/lib/CodeGen/CGExprScalar.cpp @@ -344,8 +344,7 @@ public: // C++ Value *VisitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *E) { - RValue RV = CGF.EmitLoadOfLValue(CGF.EmitLValue(E->GetTemporaryExpr())); - return RV.getScalarVal(); + return EmitLoadOfLValue(E); } Value *VisitCXXDefaultArgExpr(CXXDefaultArgExpr *DAE) { diff --git a/test/CodeGenCXX/reference-cast.cpp b/test/CodeGenCXX/reference-cast.cpp index 549434e941..1d08b2b2e4 100644 --- a/test/CodeGenCXX/reference-cast.cpp +++ b/test/CodeGenCXX/reference-cast.cpp @@ -181,3 +181,14 @@ unsigned pr10592(const int &v) { // CHECK-NEXT: ret i32 [[VVAL_I]] return static_cast(v); } + +namespace PR10650 { + struct Helper { + unsigned long long id(); + }; + unsigned long long test(Helper *obj) { + return static_cast(obj->id()); + } + // CHECK: define i64 @_ZN7PR106504testEPNS_6HelperE + // CHECK: store i64 +}