From: Richard Smith Date: Fri, 28 Sep 2018 03:18:53 +0000 (+0000) Subject: Handle dependent class template names in class template argument X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a6e89874ca806f547dfb749d3d55b54e505e32ad;p=clang Handle dependent class template names in class template argument deduction for new-expressions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@343293 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index a678a31a5a..958dd66612 100644 --- a/lib/Sema/SemaInit.cpp +++ b/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/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp b/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp index cbf7c2eee5..c310c65140 100644 --- a/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp +++ b/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 {