| 1 | // RUN: %clang_cc1 %s -verify -fsyntax-only -fdouble-square-bracket-attributes |
| 2 | |
| 3 | int f() [[deprecated]]; // expected-note 2 {{'f' has been explicitly marked deprecated here}} |
| 4 | void g() [[deprecated]];// expected-note {{'g' has been explicitly marked deprecated here}} |
| 5 | void g(); |
| 6 | |
| 7 | extern int var [[deprecated]]; // expected-note 2 {{'var' has been explicitly marked deprecated here}} |
| 8 | |
| 9 | int a() { |
| 10 | int (*ptr)() = f; // expected-warning {{'f' is deprecated}} |
| 11 | f(); // expected-warning {{'f' is deprecated}} |
| 12 | |
| 13 | // test if attributes propagate to functions |
| 14 | g(); // expected-warning {{'g' is deprecated}} |
| 15 | |
| 16 | return var; // expected-warning {{'var' is deprecated}} |
| 17 | } |
| 18 | |
| 19 | // test if attributes propagate to variables |
| 20 | extern int var; |
| 21 | int w() { |
| 22 | return var; // expected-warning {{'var' is deprecated}} |
| 23 | } |
| 24 | |
| 25 | int old_fn() [[deprecated]];// expected-note {{'old_fn' has been explicitly marked deprecated here}} |
| 26 | int old_fn(); |
| 27 | int (*fn_ptr)() = old_fn; // expected-warning {{'old_fn' is deprecated}} |
| 28 | |
| 29 | int old_fn() { |
| 30 | return old_fn()+1; // no warning, deprecated functions can use deprecated symbols. |
| 31 | } |
| 32 | |
| 33 | struct foo { |
| 34 | int x [[deprecated]]; // expected-note 3 {{'x' has been explicitly marked deprecated here}} |
| 35 | }; |
| 36 | |
| 37 | void test1(struct foo *F) { |
| 38 | ++F->x; // expected-warning {{'x' is deprecated}} |
| 39 | struct foo f1 = { .x = 17 }; // expected-warning {{'x' is deprecated}} |
| 40 | struct foo f2 = { 17 }; // expected-warning {{'x' is deprecated}} |
| 41 | } |
| 42 | |
| 43 | typedef struct foo foo_dep [[deprecated]]; // expected-note {{'foo_dep' has been explicitly marked deprecated here}} |
| 44 | foo_dep *test2; // expected-warning {{'foo_dep' is deprecated}} |
| 45 | |
| 46 | struct [[deprecated, // expected-note {{'bar_dep' has been explicitly marked deprecated here}} |
| 47 | invalid_attribute]] bar_dep ; // expected-warning {{unknown attribute 'invalid_attribute' ignored}} |
| 48 | |
| 49 | struct bar_dep *test3; // expected-warning {{'bar_dep' is deprecated}} |
| 50 | |
| 51 | [[deprecated("this is the message")]] int i; // expected-note {{'i' has been explicitly marked deprecated here}} |
| 52 | void test4(void) { |
| 53 | i = 12; // expected-warning {{'i' is deprecated: this is the message}} |
| 54 | } |
| 55 | |