Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions clang/lib/AST/DeclTemplate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1670,20 +1670,25 @@ clang::getReplacedTemplateParameter(Decl *D, unsigned Index) {
auto P = CTSD->getSpecializedTemplateOrPartial();
TemplateParameterList *TPL;
if (const auto *CTPSD =
dyn_cast<ClassTemplatePartialSpecializationDecl *>(P))
dyn_cast<ClassTemplatePartialSpecializationDecl *>(P)) {
TPL = CTPSD->getTemplateParameters();
else
TPL = cast<ClassTemplateDecl *>(P)->getTemplateParameters();
// FIXME: Obtain Args deduced for the partial specialization.
return {TPL->getParam(Index), {}};
}
TPL = cast<ClassTemplateDecl *>(P)->getTemplateParameters();
return {TPL->getParam(Index), CTSD->getTemplateArgs()[Index]};
}
case Decl::Kind::VarTemplateSpecialization: {
const auto *VTSD = cast<VarTemplateSpecializationDecl>(D);
auto P = VTSD->getSpecializedTemplateOrPartial();
TemplateParameterList *TPL;
if (const auto *VTPSD = dyn_cast<VarTemplatePartialSpecializationDecl *>(P))
if (const auto *VTPSD =
dyn_cast<VarTemplatePartialSpecializationDecl *>(P)) {
TPL = VTPSD->getTemplateParameters();
else
TPL = cast<VarTemplateDecl *>(P)->getTemplateParameters();
// FIXME: Obtain Args deduced for the partial specialization.
return {TPL->getParam(Index), {}};
}
TPL = cast<VarTemplateDecl *>(P)->getTemplateParameters();
return {TPL->getParam(Index), VTSD->getTemplateArgs()[Index]};
}
case Decl::Kind::ClassTemplatePartialSpecialization:
Expand Down
17 changes: 17 additions & 0 deletions clang/test/SemaTemplate/concepts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<e> struct s {};

template<typename> struct specialized;
template<e x> struct specialized<s<x>> {
static auto make(auto) -> s<x>;
};

template<e x> struct check {
static constexpr auto m = requires { specialized<s<x>>::make(0); };
};

template<typename... Ts> auto comma = (..., Ts());
auto b = comma<check<e{}>>;
} // namespace GH162770
13 changes: 13 additions & 0 deletions clang/test/SemaTemplate/partial-spec-instantiate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,16 @@ namespace GH60778 {
ClassTemplate<>::Nested<int> instantiation;
}
}
#if __cplusplus >= 201103L
namespace GH162855 {
template <class...> using A = int;
template <class, int> struct B;
template <class...> struct C;
template <template <class, int...> class TT, long... X>
struct C<TT<int, X...>> {
template <class... Y> using l = A<B<Y, X>...>;
};
template <class> struct D;
template struct C<D<int>>;
} // namespace GH162855
#endif