]> granicus.if.org Git - clang/commitdiff
Use SubstInitializer instead of SubstExpr when instantiating a default
authorRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 14 Oct 2016 01:12:20 +0000 (01:12 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 14 Oct 2016 01:12:20 +0000 (01:12 +0000)
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

lib/Sema/SemaExpr.cpp
test/CodeGenCXX/default-arg-temps.cpp

index 45f8ca7515b6948a61f10095a2bc575bd9472eb0..e301d789a4dc5183ffde81fb7e83dc822ec0583f 100644 (file)
@@ -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();
index 6a7f43a5128714b1bd3bf4e87a4be79a77ce1d2a..f7b46818e39dedf5bd3d17d9f977578d1cce795f 100644 (file)
@@ -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 <typename T> struct A { A() {} ~A() {} };
+  template <typename> void f(const A<int> & = {}) {}
+  void g() { f<int>(); }
+}