From 370e53864aaed0288afdf532e127efe35d4b49f1 Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Sat, 14 Nov 2009 01:51:50 +0000 Subject: [PATCH] Handle CXXDefaultArgExprs in EmitLValue. Fixes PR5484. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88735 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGExpr.cpp | 6 ++++-- test/CodeGenCXX/default-arguments.cpp | 13 +++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 test/CodeGenCXX/default-arguments.cpp diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index 63041fee82..c297903a69 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -267,6 +267,10 @@ LValue CodeGenFunction::EmitLValue(const Expr *E) { return EmitCXXBindTemporaryLValue(cast(E)); case Expr::CXXExprWithTemporariesClass: return EmitCXXExprWithTemporariesLValue(cast(E)); + case Expr::CXXZeroInitValueExprClass: + return EmitNullInitializationLValue(cast(E)); + case Expr::CXXDefaultArgExprClass: + return EmitLValue(cast(E)->getExpr()); case Expr::ObjCMessageExprClass: return EmitObjCMessageExprLValue(cast(E)); @@ -303,8 +307,6 @@ LValue CodeGenFunction::EmitLValue(const Expr *E) { case Expr::CXXReinterpretCastExprClass: case Expr::CXXConstCastExprClass: return EmitCastLValue(cast(E)); - case Expr::CXXZeroInitValueExprClass: - return EmitNullInitializationLValue(cast(E)); } } diff --git a/test/CodeGenCXX/default-arguments.cpp b/test/CodeGenCXX/default-arguments.cpp new file mode 100644 index 0000000000..5028ce99c7 --- /dev/null +++ b/test/CodeGenCXX/default-arguments.cpp @@ -0,0 +1,13 @@ +// RUN: clang-cc -emit-llvm %s -o - -triple=x86_64-apple-darwin10 + +// PR5484 +namespace PR5484 { +struct A { }; +extern A a; + +void f(const A & = a); + +void g() { + f(); +} +} -- 2.40.0