summaryrefslogtreecommitdiff
path: root/test/Sema/warn-documentation.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/Sema/warn-documentation.cpp')
-rw-r--r--test/Sema/warn-documentation.cpp72
1 files changed, 72 insertions, 0 deletions
diff --git a/test/Sema/warn-documentation.cpp b/test/Sema/warn-documentation.cpp
index 34d8f5fd2da28..0c92b2aa029fe 100644
--- a/test/Sema/warn-documentation.cpp
+++ b/test/Sema/warn-documentation.cpp
@@ -1210,3 +1210,75 @@ template <class T> T test_function (T arg);
/*! @function test_function<int>
*/
template <> int test_function<int> (int arg);
+
+namespace AllowParamAndReturnsOnFunctionPointerVars {
+
+/**
+ * functionPointerVariable
+ *
+ * @param i is integer.
+ * @returns integer.
+ */
+int (*functionPointerVariable)(int i);
+
+struct HasFields {
+ /**
+ * functionPointerField
+ *
+ * @param i is integer.
+ * @returns integer.
+ */
+ int (*functionPointerField)(int i);
+};
+
+// expected-warning@+5 {{'\returns' command used in a comment that is attached to a function returning void}}
+/**
+ * functionPointerVariable
+ *
+ * \param p not here.
+ * \returns integer.
+ */
+void (*functionPointerVariableThatLeadsNowhere)();
+
+// Still warn about param/returns commands for variables that don't specify
+// the type directly:
+
+/**
+ * FunctionPointerTypedef
+ *
+ * \param i is integer.
+ * \returns integer.
+ */
+typedef int (*FunctionPointerTypedef)(int i);
+
+/**
+ * FunctionPointerTypealias
+ *
+ * \param i is integer.
+ * \returns integer.
+ */
+using FunctionPointerTypealias = int (*)(int i);
+
+// expected-warning@+5 {{'@param' command used in a comment that is not attached to a function declaration}}
+// expected-warning@+5 {{'@returns' command used in a comment that is not attached to a function or method declaration}}
+/**
+ * functionPointerVariable
+ *
+ * @param i is integer.
+ * @returns integer.
+ */
+FunctionPointerTypedef functionPointerTypedefVariable;
+
+struct HasMoreFields {
+ // expected-warning@+5 {{'\param' command used in a comment that is not attached to a function declaration}}
+ // expected-warning@+5 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
+ /**
+ * functionPointerTypealiasField
+ *
+ * \param i is integer.
+ * \returns integer.
+ */
+ FunctionPointerTypealias functionPointerTypealiasField;
+};
+
+}