diff --git a/clang/lib/AST/CommentSema.cpp b/clang/lib/AST/CommentSema.cpp index e74c7cb5ce605..156307e7abfd5 100644 --- a/clang/lib/AST/CommentSema.cpp +++ b/clang/lib/AST/CommentSema.cpp @@ -317,8 +317,13 @@ void Sema::actOnTParamCommandParamNameArg(TParamCommandComment *Command, return; } - const TemplateParameterList *TemplateParameters = - ThisDeclInfo->TemplateParameters; + const TemplateParameterList *TemplateParameters; + if (const auto *Concept = + dyn_cast_or_null(ThisDeclInfo->CommentDecl)) + TemplateParameters = Concept->getTemplateParameters(); + else + TemplateParameters = ThisDeclInfo->TemplateParameters; + SmallVector Position; if (resolveTParamReference(Arg, TemplateParameters, &Position)) { Command->setPosition(copyArray(ArrayRef(Position))); @@ -857,7 +862,8 @@ bool Sema::isTemplateOrSpecialization() { return false; if (!ThisDeclInfo->IsFilled) inspectThisDecl(); - return ThisDeclInfo->getTemplateKind() != DeclInfo::NotTemplate; + return ThisDeclInfo->getTemplateKind() != DeclInfo::NotTemplate || + isa(ThisDeclInfo->CommentDecl); } bool Sema::isExplicitFunctionTemplateInstantiation() { diff --git a/clang/test/Sema/warn-documentation.cpp b/clang/test/Sema/warn-documentation.cpp index 24a4a22755a36..1076aa61266dc 100644 --- a/clang/test/Sema/warn-documentation.cpp +++ b/clang/test/Sema/warn-documentation.cpp @@ -1,5 +1,6 @@ // RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -verify %s // RUN: %clang_cc1 -std=c++14 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -verify %s +// RUN: %clang_cc1 -std=c++20 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -verify %s // This file contains lots of corner cases, so ensure that XML we generate is not invalid. // RUN: c-index-test -test-load-source all -comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng %s | FileCheck %s -check-prefix=WRONG @@ -1544,5 +1545,12 @@ namespace GH64087 template void foo(){} +#if __cplusplus >= 202002L +/// @tparam T Derived class. +/// @tparam TBase Base CRTP class. +template +concept bar = true; +#endif + template void foo(); } // namespace GH64087