Index: clang/lib/Sema/SemaTemplateInstantiate.cpp =================================================================== --- clang/lib/Sema/SemaTemplateInstantiate.cpp +++ clang/lib/Sema/SemaTemplateInstantiate.cpp @@ -135,11 +135,13 @@ Response HandleClassTemplateSpec(const ClassTemplateSpecializationDecl *ClassTemplSpec, MultiLevelTemplateArgumentList &Result, - bool SkipForSpecialization) { + bool SkipForSpecialization, + bool ForConstraintInstantiation) { if (!ClassTemplSpec->isClassScopeExplicitSpecialization()) { // We're done when we hit an explicit specialization. if (ClassTemplSpec->getSpecializationKind() == TSK_ExplicitSpecialization && - !isa(ClassTemplSpec)) + !isa(ClassTemplSpec) && + !ForConstraintInstantiation) return Response::Done(); if (!SkipForSpecialization) @@ -208,6 +210,18 @@ return Response::UseNextDecl(Function); } +Response HandleConstructor(const CXXConstructorDecl *Ctor, + MultiLevelTemplateArgumentList &Result, + const FunctionDecl *Pattern, bool RelativeToPrimary, + bool ForConstraintInstantiation) { + if (Ctor->isImplicit() && Ctor->isInheritingConstructor() && + Ctor->getInheritedConstructor().getConstructor()) + Ctor = Ctor->getInheritedConstructor().getConstructor(); + + return HandleFunction(Ctor, Result, Pattern, RelativeToPrimary, + ForConstraintInstantiation); +} + Response HandleRecordDecl(const CXXRecordDecl *Rec, MultiLevelTemplateArgumentList &Result, ASTContext &Context, @@ -308,8 +322,11 @@ R = HandleVarTemplateSpec(VarTemplSpec, Result, SkipForSpecialization); } else if (const auto *ClassTemplSpec = dyn_cast(CurDecl)) { - R = HandleClassTemplateSpec(ClassTemplSpec, Result, - SkipForSpecialization); + R = HandleClassTemplateSpec(ClassTemplSpec, Result, SkipForSpecialization, + ForConstraintInstantiation); + } else if (const auto *Ctor = dyn_cast(CurDecl)) { + R = HandleConstructor(Ctor, Result, Pattern, RelativeToPrimary, + ForConstraintInstantiation); } else if (const auto *Function = dyn_cast(CurDecl)) { R = HandleFunction(Function, Result, Pattern, RelativeToPrimary, ForConstraintInstantiation); Index: clang/test/SemaTemplate/concepts.cpp =================================================================== --- clang/test/SemaTemplate/concepts.cpp +++ clang/test/SemaTemplate/concepts.cpp @@ -816,3 +816,26 @@ static_assert(Parent::TakesBinary::i == 0); } +namespace GH62362 { +template +concept C = true; + +template struct Test { + Test() + requires(C); +}; + +struct Bar : public Test { + using Test::Test; +}; + +template <> +struct Test : public Test { + using Test::Test; +}; + +void foo() { + Bar(); + Test(); +} +}