From: Richard Smith Date: Fri, 14 Oct 2016 01:12:20 +0000 (+0000) Subject: Use SubstInitializer instead of SubstExpr when instantiating a default X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2875f6c8b4da9d3c9fce7f958d1f46d797f67475;p=clang Use SubstInitializer instead of SubstExpr when instantiating a default argument, in order to correctly instantiate the initializer. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@284184 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 45f8ca7515..e301d789a4 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -4559,7 +4559,8 @@ ExprResult Sema::BuildCXXDefaultArgExpr(SourceLocation CallLoc, // default argument expression appears. ContextRAII SavedContext(*this, FD); LocalInstantiationScope Local(*this); - Result = SubstExpr(UninstExpr, MutiLevelArgList); + Result = SubstInitializer(UninstExpr, MutiLevelArgList, + /*DirectInit*/false); } if (Result.isInvalid()) return ExprError(); diff --git a/test/CodeGenCXX/default-arg-temps.cpp b/test/CodeGenCXX/default-arg-temps.cpp index 6a7f43a512..f7b46818e3 100644 --- a/test/CodeGenCXX/default-arg-temps.cpp +++ b/test/CodeGenCXX/default-arg-temps.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 | FileCheck %s +// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 | FileCheck %s struct T { T(); @@ -71,3 +71,10 @@ namespace test1 { D d; } + +namespace test2 { + // CHECK: define linkonce_odr void @_ZN5test21AIiED2Ev( + template struct A { A() {} ~A() {} }; + template void f(const A & = {}) {} + void g() { f(); } +}