Skip to content

Commit 28649f2

Browse files
authored
[Clang] accept @tparam on variable template partial specializations (#147219)
Fixes #144775 --- This patch addresses a false-positive `-Wdocumentation` warning on `@tparam` comments attached to _variable template partial specializations_
1 parent 68309ad commit 28649f2

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,8 @@ Improvements to Clang's diagnostics
675675
false positives in exception-heavy code, though only simple patterns
676676
are currently recognized.
677677

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

679681
Improvements to Clang's time-trace
680682
----------------------------------

clang/lib/AST/Comment.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,13 @@ void DeclInfo::fill() {
291291
TemplateParameters = CTPSD->getTemplateParameters();
292292
break;
293293
}
294+
case Decl::VarTemplatePartialSpecialization: {
295+
const auto *VTPSD = cast<VarTemplatePartialSpecializationDecl>(CommentDecl);
296+
Kind = VariableKind;
297+
TemplateKind = TemplatePartialSpecialization;
298+
TemplateParameters = VTPSD->getTemplateParameters();
299+
break;
300+
}
294301
case Decl::ClassTemplateSpecialization:
295302
Kind = ClassKind;
296303
TemplateKind = TemplateSpecialization;

clang/test/Sema/warn-documentation.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,3 +1524,15 @@ F &f = FF; ///< \return none
15241524
// expected-warning@-1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
15251525

15261526
} // namespace PR42844
1527+
1528+
#if __cplusplus >= 201402L
1529+
namespace GH144775 {
1530+
/// @brief primary template
1531+
/// @tparam T type
1532+
template <class T, class = void> constexpr auto var = T{};
1533+
1534+
/// @brief variable template partial specialization
1535+
/// @tparam T type
1536+
template <typename T> constexpr auto var<T> = T{};
1537+
} // namespace GH144775
1538+
#endif

0 commit comments

Comments
 (0)