diff options
author | Dmitri Gribenko <gribozavr@gmail.com> | 2012-09-22 21:47:50 +0000 |
---|---|---|
committer | Dmitri Gribenko <gribozavr@gmail.com> | 2012-09-22 21:47:50 +0000 |
commit | 1da888691587e6dd338b70b97c02a740e29c99dc (patch) | |
tree | 739b4ba38689ddb34c3b562b74a1aa911c4af934 /clang/test | |
parent | d0885d2941d437026e60b79425a08cbf44ee069a (diff) | |
download | bcm5719-llvm-1da888691587e6dd338b70b97c02a740e29c99dc.tar.gz bcm5719-llvm-1da888691587e6dd338b70b97c02a740e29c99dc.zip |
Comment sema: warn when comment has \deprecated but declaration does not have a
deprecation attribute ('deprecated', 'availability' or 'unavailable').
This warning is under a separate flag, -Wdocumentation-deprecated-sync, so it
can be turned off easily while leaving other -Wdocumentation warnings on.
llvm-svn: 164467
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/Sema/warn-documentation-fixits.cpp | 37 | ||||
-rw-r--r-- | clang/test/Sema/warn-documentation.cpp | 29 |
2 files changed, 64 insertions, 2 deletions
diff --git a/clang/test/Sema/warn-documentation-fixits.cpp b/clang/test/Sema/warn-documentation-fixits.cpp index 732b44db027..812d404e68d 100644 --- a/clang/test/Sema/warn-documentation-fixits.cpp +++ b/clang/test/Sema/warn-documentation-fixits.cpp @@ -20,8 +20,45 @@ void test3(T aaa); template<typename SomeTy, typename OtherTy> void test4(SomeTy aaa, OtherTy bbb); +// 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}} +/// \deprecated +void test_deprecated_1(); + +// 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}} +/// \deprecated +void test_deprecated_2(int a); + +struct test_deprecated_3 { + // 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}} + /// \deprecated + void test_deprecated_4(); + + // 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}} + /// \deprecated + void test_deprecated_5() { + } +}; + +template<typename T> +struct test_deprecated_6 { + // 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}} + /// \deprecated + void test_deprecated_7(); + + // 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}} + /// \deprecated + void test_deprecated_8() { + } +}; + // CHECK: fix-it:"{{.*}}":{5:12-5:22}:"a" // CHECK: fix-it:"{{.*}}":{9:12-9:15}:"aaa" // CHECK: fix-it:"{{.*}}":{13:13-13:23}:"T" // CHECK: fix-it:"{{.*}}":{18:13-18:18}:"SomeTy" +// CHECK: fix-it:"{{.*}}":{25:25-25:25}:" __attribute__((deprecated))" +// CHECK: fix-it:"{{.*}}":{29:30-29:30}:" __attribute__((deprecated))" +// CHECK: fix-it:"{{.*}}":{34:27-34:27}:" __attribute__((deprecated))" +// CHECK: fix-it:"{{.*}}":{38:27-38:27}:" __attribute__((deprecated))" +// CHECK: fix-it:"{{.*}}":{46:27-46:27}:" __attribute__((deprecated))" +// CHECK: fix-it:"{{.*}}":{50:27-50:27}:" __attribute__((deprecated))" diff --git a/clang/test/Sema/warn-documentation.cpp b/clang/test/Sema/warn-documentation.cpp index 649f072ab97..b5d3300efd0 100644 --- a/clang/test/Sema/warn-documentation.cpp +++ b/clang/test/Sema/warn-documentation.cpp @@ -380,14 +380,39 @@ using test_tparam15 = test_tparam13<T, int>; /// Aaa /// \deprecated Bbb -void test_deprecated_1(int a); +void test_deprecated_1(int a) __attribute__((deprecated)); // We don't want \deprecated to warn about empty paragraph. It is fine to use // \deprecated by itself without explanations. /// Aaa /// \deprecated -void test_deprecated_2(int a); +void test_deprecated_2(int a) __attribute__((deprecated)); + +/// Aaa +/// \deprecated +void test_deprecated_3(int a) __attribute__((availability(macosx,introduced=10.4))); + +/// Aaa +/// \deprecated +void test_deprecated_4(int a) __attribute__((unavailable)); + +// expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}} expected-note@+3 {{add a deprecation attribute to the declaration to silence this warning}} +/// Aaa +/// \deprecated +void test_deprecated_5(int a); + +// expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}} expected-note@+3 {{add a deprecation attribute to the declaration to silence this warning}} +/// Aaa +/// \deprecated +void test_deprecated_6(int a) { +} + +// expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}} +/// Aaa +/// \deprecated +template<typename T> +void test_deprecated_7(T aaa); /// \invariant aaa |