Skip to content

Commit

Permalink
[concepts] Fixes for gh72557
Browse files Browse the repository at this point in the history
  • Loading branch information
zyn0217 committed Feb 4, 2024
1 parent 141de74 commit c04bb95
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
3 changes: 3 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ Bug Fixes to C++ Support
Fixes (`#67976 <https://github.com/llvm/llvm-project/issues/67976>`_)
- Fix crash and diagnostic with const qualified member operator new.
Fixes (`#79748 <https://github.com/llvm/llvm-project/issues/79748>`_)
- Fixed a crash where substituting into a requires-expression that involves parameter packs
during the equivalence determination of two constraint expressions.
(`#72557 <https://github.com/llvm/llvm-project/issues/72557>`_)

Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
15 changes: 13 additions & 2 deletions clang/lib/Sema/SemaTemplateInstantiate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,21 @@ Response HandleFunctionTemplateDecl(const FunctionTemplateDecl *FTD,

while (const Type *Ty = NNS ? NNS->getAsType() : nullptr) {
if (NNS->isInstantiationDependent()) {
if (const auto *TSTy = Ty->getAs<TemplateSpecializationType>())
if (const auto *TSTy = Ty->getAs<TemplateSpecializationType>()) {
ArrayRef<TemplateArgument> Arguments = TSTy->template_arguments();
if (TSTy->isCurrentInstantiation()) {
auto *RD = TSTy->getCanonicalTypeInternal()->getAsCXXRecordDecl();
if (ClassTemplateDecl *CTD = RD->getDescribedClassTemplate())
Arguments = CTD->getInjectedTemplateArgs();
else if (auto *Specializtion =
dyn_cast<ClassTemplateSpecializationDecl>(RD))
Arguments =
Specializtion->getTemplateInstantiationArgs().asArray();
}
Result.addOuterTemplateArguments(
const_cast<FunctionTemplateDecl *>(FTD), TSTy->template_arguments(),
const_cast<FunctionTemplateDecl *>(FTD), Arguments,
/*Final=*/false);
}
}

NNS = NNS->getPrefix();
Expand Down
18 changes: 18 additions & 0 deletions clang/test/SemaTemplate/concepts-out-of-line-def.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -581,3 +581,21 @@ void S<T>::test(T target, U... value)
}
{}
} // namespace GH74447

namespace GH72557 {

template <typename...>
concept IsAnyOf = true;

template <class... DerTs> struct DerivedCollection {
template <class DerT>
requires IsAnyOf<DerTs...>
unsigned long index();
};

template <class... DerTs>
template <class DerT>
requires IsAnyOf<DerTs...>
unsigned long DerivedCollection<DerTs...>::index() {}

} // namespace GH72557

0 comments on commit c04bb95

Please sign in to comment.