[cfe-commits] r91733 - in /cfe/trunk: lib/CodeGen/CGExpr.cpp test/CodeGenCXX/reference-bind-default-argument.cpp
Eli Friedman
eli.friedman at gmail.com
Fri Dec 18 16:20:11 PST 2009
Author: efriedma
Date: Fri Dec 18 18:20:10 2009
New Revision: 91733
URL: http://llvm.org/viewvc/llvm-project?rev=91733&view=rev
Log:
Fix for PR5524: make reference binding in default argument work correctly.
Added:
cfe/trunk/test/CodeGenCXX/reference-bind-default-argument.cpp
Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=91733&r1=91732&r2=91733&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Fri Dec 18 18:20:10 2009
@@ -97,7 +97,10 @@
bool IsInitializer) {
bool ShouldDestroyTemporaries = false;
unsigned OldNumLiveTemporaries = 0;
-
+
+ if (const CXXDefaultArgExpr *DAE = dyn_cast<CXXDefaultArgExpr>(E))
+ E = DAE->getExpr();
+
if (const CXXExprWithTemporaries *TE = dyn_cast<CXXExprWithTemporaries>(E)) {
ShouldDestroyTemporaries = true;
Added: cfe/trunk/test/CodeGenCXX/reference-bind-default-argument.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/reference-bind-default-argument.cpp?rev=91733&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/reference-bind-default-argument.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/reference-bind-default-argument.cpp Fri Dec 18 18:20:10 2009
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 %s -emit-llvm-only -verify
+
+struct A {};
+struct B : A {};
+void a(const A& x = B());
+void b() { a(); }
More information about the cfe-commits
mailing list