]> granicus.if.org Git - clang/commitdiff
Comment parsing: recognize \param ... on function templates with variadic
authorDmitri Gribenko <gribozavr@gmail.com>
Wed, 19 Mar 2014 13:59:36 +0000 (13:59 +0000)
committerDmitri Gribenko <gribozavr@gmail.com>
Wed, 19 Mar 2014 13:59:36 +0000 (13:59 +0000)
parameters

Patch by Joe Ranieri.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204235 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/CommentSema.cpp
test/Sema/warn-documentation.cpp

index 0ae00820fde6df6c9f27fa1216e02e2033cadddf..e51f8781c1b0ca67d6b7daf2c142c9dc6a7af5e7 100644 (file)
@@ -792,11 +792,14 @@ bool Sema::isAnyFunctionDecl() {
 }
 
 bool Sema::isFunctionOrMethodVariadic() {
-  if (!isAnyFunctionDecl() && !isObjCMethodDecl())
+  if (!isAnyFunctionDecl() && !isObjCMethodDecl() && !isFunctionTemplateDecl())
     return false;
   if (const FunctionDecl *FD =
         dyn_cast<FunctionDecl>(ThisDeclInfo->CurrentDecl))
     return FD->isVariadic();
+  if (const FunctionTemplateDecl *FTD =
+        dyn_cast<FunctionTemplateDecl>(ThisDeclInfo->CurrentDecl))
+    return FTD->getTemplatedDecl()->isVariadic();
   if (const ObjCMethodDecl *MD =
         dyn_cast<ObjCMethodDecl>(ThisDeclInfo->CurrentDecl))
     return MD->isVariadic();
index ad7ab181a78a8ee98bc0fcb53c69020d86fb1997..ed25d949f5594b3bad4b2d8be42b576c4a96f7d5 100644 (file)
@@ -371,6 +371,26 @@ int test_vararg_param3(int aaa);
 int test_vararg_param4();
 
 
+/// \param aaa Aaa
+/// \param ... Vararg
+template<typename T>
+int test_template_vararg_param1(int aaa, ...);
+
+/// \param ... Vararg
+template<typename T>
+int test_template_vararg_param2(...);
+
+// expected-warning@+1 {{parameter '...' not found in the function declaration}} expected-note@+1 {{did you mean 'aaa'?}}
+/// \param ... Vararg
+template<typename T>
+int test_template_vararg_param3(int aaa);
+
+// expected-warning@+1 {{parameter '...' not found in the function declaration}}
+/// \param ... Vararg
+template<typename T>
+int test_template_vararg_param4();
+
+
 // expected-warning@+1 {{'\tparam' command used in a comment that is not attached to a template declaration}}
 /// \tparam T Aaa
 int test_tparam1;