[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / Sema / warn-documentation-fixits.cpp
blob871ac00ba8679bd997745169d71e09ddd7fc379d
1 // RUN: %clang_cc1 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -fcomment-block-commands=foobar -verify %s
2 // RUN %clang_cc1 -std=c++11 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -fcomment-block-commands=foobar -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck -DATTRIBUTE="__attribute__((deprecated))" %s
3 // RUN: %clang_cc1 -std=c++14 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -fcomment-block-commands=foobar -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck --check-prefixes=CHECK,CHECK14 -DATTRIBUTE="[[deprecated]]" %s
5 // expected-warning@+1 {{parameter 'ZZZZZZZZZZ' not found in the function declaration}} expected-note@+1 {{did you mean 'a'?}}
6 /// \param ZZZZZZZZZZ Blah blah.
7 int test1(int a);
9 // expected-warning@+1 {{parameter 'aab' not found in the function declaration}} expected-note@+1 {{did you mean 'aaa'?}}
10 /// \param aab Blah blah.
11 int test2(int aaa, int bbb);
13 // expected-warning@+1 {{template parameter 'ZZZZZZZZZZ' not found in the template declaration}} expected-note@+1 {{did you mean 'T'?}}
14 /// \tparam ZZZZZZZZZZ Aaa
15 template<typename T>
16 void test3(T aaa);
18 // expected-warning@+1 {{template parameter 'SomTy' not found in the template declaration}} expected-note@+1 {{did you mean 'SomeTy'?}}
19 /// \tparam SomTy Aaa
20 /// \tparam OtherTy Bbb
21 template<typename SomeTy, typename OtherTy>
22 void test4(SomeTy aaa, OtherTy bbb);
24 // expected-warning@+1 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}} expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
25 /// \deprecated
26 void test_deprecated_1();
28 // expected-warning@+1 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}} expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
29 /// \deprecated
30 void test_deprecated_2(int a);
32 struct test_deprecated_3 {
33 // expected-warning@+1 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}} expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
34 /// \deprecated
35 void test_deprecated_4();
37 // expected-warning@+1 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}} expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
38 /// \deprecated
39 void test_deprecated_5() {
43 template<typename T>
44 struct test_deprecated_6 {
45 // expected-warning@+1 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}} expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
46 /// \deprecated
47 void test_deprecated_7();
49 // expected-warning@+1 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}} expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
50 /// \deprecated
51 void test_deprecated_8() {
55 class PR43753 {
56 // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}}
57 // expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
58 /// \deprecated
59 static void test_deprecated_static();
61 // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}}
62 // expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
63 /// \deprecated
64 static auto test_deprecated_static_trailing_return() -> int;
66 #if __cplusplus >= 201402L
67 // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}}
68 // expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
69 /// \deprecated
70 static decltype(auto) test_deprecated_static_decltype_auto() { return 1; }
71 #endif
73 // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}}
74 // expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
75 /// \deprecated
76 void test_deprecated_const() const;
78 // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}}
79 // expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
80 /// \deprecated
81 auto test_deprecated_trailing_return() -> int;
83 #if __cplusplus >= 201402L
84 // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}}
85 // expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
86 /// \deprecated
87 decltype(auto) test_deprecated_decltype_auto() const { return a; }
89 private:
90 int a{0};
91 #endif
93 #define MY_ATTR_DEPRECATED __attribute__((deprecated))
95 // expected-warning@+1 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}} expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
96 /// \deprecated
97 void test_deprecated_9(int a);
99 #if __cplusplus >= 201402L
100 #define ATTRIBUTE_DEPRECATED [[deprecated]]
102 // expected-warning@+1 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}} expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
103 /// \deprecated
104 void test_deprecated_10(int a);
105 #endif
107 // rdar://12381408
108 // expected-warning@+2 {{unknown command tag name 'retur'; did you mean 'return'?}}
109 /// \brief testing fixit
110 /// \retur int in FooBar
111 int FooBar();
113 // expected-warning@+1 {{unknown command tag name 'fooba'; did you mean 'foobar'?}}
114 /// \fooba bbb IS_DOXYGEN_END
115 int gorf();
117 // expected-warning@+1 {{unknown command tag name}}
118 /// \t bbb IS_DOXYGEN_END
119 int Bar();
121 // expected-warning@+2 {{unknown command tag name 'encode'; did you mean 'endcode'?}}
122 // expected-warning@+1 {{'\endcode' command does not terminate a verbatim text block}}
123 /// \encode PR18051
124 int PR18051();
126 // CHECK: fix-it:"{{.*}}":{6:12-6:22}:"a"
127 // CHECK: fix-it:"{{.*}}":{10:12-10:15}:"aaa"
128 // CHECK: fix-it:"{{.*}}":{14:13-14:23}:"T"
129 // CHECK: fix-it:"{{.*}}":{19:13-19:18}:"SomeTy"
130 // CHECK: fix-it:"{{.*}}":{26:1-26:1}:"[[ATTRIBUTE]] "
131 // CHECK: fix-it:"{{.*}}":{30:1-30:1}:"[[ATTRIBUTE]] "
132 // CHECK: fix-it:"{{.*}}":{35:3-35:3}:"[[ATTRIBUTE]] "
133 // CHECK: fix-it:"{{.*}}":{39:3-39:3}:"[[ATTRIBUTE]] "
134 // CHECK: fix-it:"{{.*}}":{47:3-47:3}:"[[ATTRIBUTE]] "
135 // CHECK: fix-it:"{{.*}}":{51:3-51:3}:"[[ATTRIBUTE]] "
136 // CHECK: fix-it:"{{.*}}":{76:3-76:3}:"[[ATTRIBUTE]] "
137 // CHECK: fix-it:"{{.*}}":{81:3-81:3}:"[[ATTRIBUTE]] "
138 // CHECK14: fix-it:"{{.*}}":{87:3-87:3}:"[[ATTRIBUTE]] "
139 // CHECK: fix-it:"{{.*}}":{97:1-97:1}:"MY_ATTR_DEPRECATED "
140 // CHECK14: fix-it:"{{.*}}":{104:1-104:1}:"ATTRIBUTE_DEPRECATED "
141 // CHECK: fix-it:"{{.*}}":{110:6-110:11}:"return"
142 // CHECK: fix-it:"{{.*}}":{114:6-114:11}:"foobar"
143 // CHECK: fix-it:"{{.*}}":{123:6-123:12}:"endcode"