diff options
author | John McCall <rjmccall@apple.com> | 2009-11-04 02:18:39 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2009-11-04 02:18:39 +0000 |
commit | 54abf7d4fa3123b8324c09d2a4dfb789fd818403 (patch) | |
tree | e0a899f37d5b05f29b984352e1d9f09b610e12f5 /test/Sema/attr-deprecated.c | |
parent | 05a2338f7ba1c8a0136e120502f80a38cf0e9fd3 (diff) | |
download | clang-54abf7d4fa3123b8324c09d2a4dfb789fd818403.tar.gz |
Change our basic strategy for avoiding deprecation warnings when the decl use
appears in a deprecated context. In the new strategy, we emit the warnings
as usual unless we're currently parsing a declaration, where "declaration" is
restricted to mean a decl group or a few special cases in Objective C. If
we *are* parsing a declaration, we queue up the deprecation warnings until
the declaration has been completely parsed, and then emit them only if the
decl is not deprecated.
We also standardize the bookkeeping for deprecation so as to avoid special cases.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85998 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Sema/attr-deprecated.c')
-rw-r--r-- | test/Sema/attr-deprecated.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/test/Sema/attr-deprecated.c b/test/Sema/attr-deprecated.c index 527f0106d4..4b889fc8aa 100644 --- a/test/Sema/attr-deprecated.c +++ b/test/Sema/attr-deprecated.c @@ -55,3 +55,48 @@ struct bar_dep *test3; // expected-warning {{'bar_dep' is deprecated}} foo_dep *test4 __attribute__((deprecated)); struct bar_dep *test5 __attribute__((deprecated)); +typedef foo_dep test6(struct bar_dep*); // expected-warning {{'foo_dep' is deprecated}} \ + // expected-warning {{'bar_dep' is deprecated}} +typedef foo_dep test7(struct bar_dep*) __attribute__((deprecated)); + +int test8(char *p) { + p += sizeof(foo_dep); // expected-warning {{'foo_dep' is deprecated}} + + foo_dep *ptr; // expected-warning {{'foo_dep' is deprecated}} + ptr = (foo_dep*) p; // expected-warning {{'foo_dep' is deprecated}} + + int func(foo_dep *foo); // expected-warning {{'foo_dep' is deprecated}} + return func(ptr); +} + +foo_dep *test9(void) __attribute__((deprecated)); +foo_dep *test9(void) { + void* myalloc(unsigned long); + + foo_dep *ptr + = (foo_dep*) + myalloc(sizeof(foo_dep)); + return ptr; +} + +void test10(void) __attribute__((deprecated)); +void test10(void) { + if (sizeof(foo_dep) == sizeof(void*)) { + } + foo_dep *localfunc(void); + foo_dep localvar; +} + +char test11[sizeof(foo_dep)] __attribute__((deprecated)); +char test12[sizeof(foo_dep)]; // expected-warning {{'foo_dep' is deprecated}} + +int test13(foo_dep *foo) __attribute__((deprecated)); +int test14(foo_dep *foo); // expected-warning {{'foo_dep' is deprecated}} + +unsigned long test15 = sizeof(foo_dep); // expected-warning {{'foo_dep' is deprecated}} +unsigned long test16 __attribute__((deprecated)) + = sizeof(foo_dep); + +foo_dep test17, // expected-warning {{'foo_dep' is deprecated}} + test18 __attribute__((deprecated)), + test19; |