diff options
Diffstat (limited to 'test/Sema/attr-deprecated.c')
| -rw-r--r-- | test/Sema/attr-deprecated.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/test/Sema/attr-deprecated.c b/test/Sema/attr-deprecated.c index e15381e4c6d1..4b889fc8aa4f 100644 --- a/test/Sema/attr-deprecated.c +++ b/test/Sema/attr-deprecated.c @@ -43,3 +43,60 @@ void test1(struct foo *F) { typedef struct foo foo_dep __attribute__((deprecated)); foo_dep *test2; // expected-warning {{'foo_dep' is deprecated}} + +struct bar_dep __attribute__((deprecated, + invalid_attribute)); // expected-warning {{'invalid_attribute' attribute ignored}} + +struct bar_dep *test3; // expected-warning {{'bar_dep' is deprecated}} + + +// These should not warn because the actually declaration itself is deprecated. +// rdar://6756623 +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; |
