[clang] [Clang][Sema] Refactor collection of multi-level template argument lists (PR #106585)
Krystian Stasiowski via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 3 06:39:57 PDT 2024
================
@@ -2112,6 +2078,33 @@ DeclResult Sema::CheckClassTemplate(
NewClass->setLexicalDeclContext(CurContext);
NewTemplate->setLexicalDeclContext(CurContext);
+ // Ensure that the template parameter lists are compatible. Skip this check
+ // for a friend in a dependent context: the template parameter list itself
+ // could be dependent.
+ if (ShouldAddRedecl && PrevClassTemplate &&
+ !TemplateParameterListsAreEqual(
+ NewTemplate, TemplateParams, PrevClassTemplate,
+ PrevClassTemplate->getTemplateParameters(),
+ /*Complain=*/true, TPL_TemplateMatch))
+ return true;
+
+ // Check the template parameter list of this declaration, possibly
+ // merging in the template parameter list from the previous class
+ // template declaration. Skip this check for a friend in a dependent
+ // context, because the template parameter list might be dependent.
+ if (ShouldAddRedecl &&
+ CheckTemplateParameterList(
+ TemplateParams,
+ PrevClassTemplate ? PrevClassTemplate->getTemplateParameters()
+ : nullptr,
+ (SS.isSet() && SemanticContext && SemanticContext->isRecord() &&
+ SemanticContext->isDependentContext())
+ ? TPC_ClassTemplateMember
+ : TUK == TagUseKind::Friend ? TPC_FriendClassTemplate
+ : TPC_ClassTemplate,
+ SkipBody))
----------------
sdkrystian wrote:
@zyn0217 Since this is existing code which I moved, I would prefer to keep it as-is and perhaps address this in some future NFC patch.
https://github.com/llvm/llvm-project/pull/106585
More information about the cfe-commits
mailing list