Skip to content

[Clang] accept @tparam on variable template partial specializations #147219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 7, 2025
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
2 changes: 2 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,8 @@ Improvements to Clang's diagnostics
false positives in exception-heavy code, though only simple patterns
are currently recognized.

- Clang now accepts ``@tparam`` comments on variable template partial
specializations. (#GH144775)

Improvements to Clang's time-trace
----------------------------------
Expand Down
7 changes: 7 additions & 0 deletions clang/lib/AST/Comment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,13 @@ void DeclInfo::fill() {
TemplateParameters = CTPSD->getTemplateParameters();
break;
}
case Decl::VarTemplatePartialSpecialization: {
const auto *VTPSD = cast<VarTemplatePartialSpecializationDecl>(CommentDecl);
Kind = VariableKind;
TemplateKind = TemplatePartialSpecialization;
TemplateParameters = VTPSD->getTemplateParameters();
break;
}
case Decl::ClassTemplateSpecialization:
Kind = ClassKind;
TemplateKind = TemplateSpecialization;
Expand Down
12 changes: 12 additions & 0 deletions clang/test/Sema/warn-documentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1524,3 +1524,15 @@ F &f = FF; ///< \return none
// expected-warning@-1 {{'\return' command used in a comment that is not attached to a function or method declaration}}

} // namespace PR42844

#if __cplusplus >= 201402L
namespace GH144775 {
/// @brief primary template
/// @tparam T type
template <class T, class = void> constexpr auto var = T{};

/// @brief variable template partial specialization
/// @tparam T type
template <typename T> constexpr auto var<T> = T{};
} // namespace GH144775
#endif