diff --git a/clang/lib/AST/DeclTemplate.cpp b/clang/lib/AST/DeclTemplate.cpp index c0be986824cff..2f7ae6d6cac63 100644 --- a/clang/lib/AST/DeclTemplate.cpp +++ b/clang/lib/AST/DeclTemplate.cpp @@ -1670,20 +1670,25 @@ clang::getReplacedTemplateParameter(Decl *D, unsigned Index) { auto P = CTSD->getSpecializedTemplateOrPartial(); TemplateParameterList *TPL; if (const auto *CTPSD = - dyn_cast(P)) + dyn_cast(P)) { TPL = CTPSD->getTemplateParameters(); - else - TPL = cast(P)->getTemplateParameters(); + // FIXME: Obtain Args deduced for the partial specialization. + return {TPL->getParam(Index), {}}; + } + TPL = cast(P)->getTemplateParameters(); return {TPL->getParam(Index), CTSD->getTemplateArgs()[Index]}; } case Decl::Kind::VarTemplateSpecialization: { const auto *VTSD = cast(D); auto P = VTSD->getSpecializedTemplateOrPartial(); TemplateParameterList *TPL; - if (const auto *VTPSD = dyn_cast(P)) + if (const auto *VTPSD = + dyn_cast(P)) { TPL = VTPSD->getTemplateParameters(); - else - TPL = cast(P)->getTemplateParameters(); + // FIXME: Obtain Args deduced for the partial specialization. + return {TPL->getParam(Index), {}}; + } + TPL = cast(P)->getTemplateParameters(); return {TPL->getParam(Index), VTSD->getTemplateArgs()[Index]}; } case Decl::Kind::ClassTemplatePartialSpecialization: diff --git a/clang/test/SemaTemplate/concepts.cpp b/clang/test/SemaTemplate/concepts.cpp index 768af09afe9e2..1dbb9897f941f 100644 --- a/clang/test/SemaTemplate/concepts.cpp +++ b/clang/test/SemaTemplate/concepts.cpp @@ -1476,3 +1476,20 @@ static_assert( requires {{ &f } -> C;} ); // expected-error {{reference to overl // expected-error@-1 {{static assertion failed due to requirement 'requires { { &f() } -> C; }'}} } + +namespace GH162770 { + enum e {}; + template struct s {}; + + template struct specialized; + template struct specialized> { + static auto make(auto) -> s; + }; + + template struct check { + static constexpr auto m = requires { specialized>::make(0); }; + }; + + template auto comma = (..., Ts()); + auto b = comma>; +} // namespace GH162770 diff --git a/clang/test/SemaTemplate/partial-spec-instantiate.cpp b/clang/test/SemaTemplate/partial-spec-instantiate.cpp index 0b84df69562e2..44b58008a1d33 100644 --- a/clang/test/SemaTemplate/partial-spec-instantiate.cpp +++ b/clang/test/SemaTemplate/partial-spec-instantiate.cpp @@ -152,3 +152,16 @@ namespace GH60778 { ClassTemplate<>::Nested instantiation; } } +#if __cplusplus >= 201103L +namespace GH162855 { + template using A = int; + template struct B; + template struct C; + template