From cff420120f944b012850ba279f0ec50b72571aca Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Fri, 28 Sep 2018 03:18:53 +0000 Subject: [PATCH] Handle dependent class template names in class template argument deduction for new-expressions. llvm-svn: 343293 --- clang/lib/Sema/SemaInit.cpp | 5 ++++- .../SemaCXX/cxx1z-class-template-argument-deduction.cpp | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index a678a31a5ac4..958dd66612c7 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -9155,8 +9155,11 @@ QualType Sema::DeduceTemplateSpecializationFromInitializer( TSInfo->getType()->getContainedDeducedType()); assert(DeducedTST && "not a deduced template specialization type"); - // We can only perform deduction for class templates. auto TemplateName = DeducedTST->getTemplateName(); + if (TemplateName.isDependent()) + return Context.DependentTy; + + // We can only perform deduction for class templates. auto *Template = dyn_cast_or_null(TemplateName.getAsTemplateDecl()); if (!Template) { diff --git a/clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp b/clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp index cbf7c2eee51c..c310c651408d 100644 --- a/clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp +++ b/clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp @@ -307,6 +307,13 @@ namespace dependent { template int Var(int); template int Cast(int); template int New(int); + + template typename Y> void test() { + Y(0); + new Y(0); + Y y(0); + } + template void test(); } namespace injected_class_name {