From c9320095d0126a104552ae718af461ad53316a34 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Mon, 4 Mar 2013 20:08:47 +0000 Subject: [PATCH] [comment parsing] source fidelity for tparam command too. // rdar://13066276 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176448 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/DiagnosticCommentKinds.td | 4 ++-- lib/AST/CommentSema.cpp | 1 + test/Sema/warn-documentation.cpp | 4 ++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/clang/Basic/DiagnosticCommentKinds.td b/include/clang/Basic/DiagnosticCommentKinds.td index 73c0dc9dd0..829f98dfd7 100644 --- a/include/clang/Basic/DiagnosticCommentKinds.td +++ b/include/clang/Basic/DiagnosticCommentKinds.td @@ -87,10 +87,10 @@ def warn_doc_param_not_found : Warning< def note_doc_param_name_suggestion : Note< "did you mean '%0'?">; -// \tparam command +// tparam command def warn_doc_tparam_not_attached_to_a_template_decl : Warning< - "'\\tparam' command used in a comment that is not attached to " + "'%select{\\|@}0tparam' command used in a comment that is not attached to " "a template declaration">, InGroup, DefaultIgnore; diff --git a/lib/AST/CommentSema.cpp b/lib/AST/CommentSema.cpp index 3e4b28356b..dab48e05df 100644 --- a/lib/AST/CommentSema.cpp +++ b/lib/AST/CommentSema.cpp @@ -173,6 +173,7 @@ TParamCommandComment *Sema::actOnTParamCommandStart(SourceLocation LocBegin, if (!isTemplateOrSpecialization()) Diag(Command->getLocation(), diag::warn_doc_tparam_not_attached_to_a_template_decl) + << AtCommand << Command->getCommandNameRange(Traits); return Command; diff --git a/test/Sema/warn-documentation.cpp b/test/Sema/warn-documentation.cpp index 220f84508f..d054fac990 100644 --- a/test/Sema/warn-documentation.cpp +++ b/test/Sema/warn-documentation.cpp @@ -799,6 +799,10 @@ void test_attach37::test_attach38(int aaa, int bbb) {} template void test_attach37::test_attach39(int aaa, int bbb) {} +// expected-warning@+1 {{'@tparam' command used in a comment that is not attached to a template declaration}} +/// @tparam T Aaa +int test_tparam22; + // We used to emit warning that parameter 'a' is not found because we parsed // the comment in context of the redeclaration which does not have parameter // names. -- 2.40.0