1 // RUN: %clang_cc1 %s -verify -fsyntax-only -std=c2x
3 [[deprecated
]] int f(void); // expected-note 2 {{'f' has been explicitly marked deprecated here}}
4 [[deprecated
]] void g(void);// expected-note {{'g' has been explicitly marked deprecated here}}
7 extern int var
[[deprecated
]]; // expected-note 2 {{'var' has been explicitly marked deprecated here}}
10 int (*ptr
)(void) = f
; // expected-warning {{'f' is deprecated}}
11 f(); // expected-warning {{'f' is deprecated}}
13 // test if attributes propagate to functions
14 g(); // expected-warning {{'g' is deprecated}}
16 return var
; // expected-warning {{'var' is deprecated}}
19 // test if attributes propagate to variables
22 return var
; // expected-warning {{'var' is deprecated}}
25 [[deprecated
]] int old_fn(void);// expected-note {{'old_fn' has been explicitly marked deprecated here}}
27 int (*fn_ptr
)(void) = old_fn
; // expected-warning {{'old_fn' is deprecated}}
30 return old_fn()+1; // no warning, deprecated functions can use deprecated symbols.
34 int x
[[deprecated
]]; // expected-note 3 {{'x' has been explicitly marked deprecated here}}
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}}
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}}
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}}
49 struct bar_dep
*test3
; // expected-warning {{'bar_dep' is deprecated}}
51 [[deprecated("this is the message")]] int i
; // expected-note {{'i' has been explicitly marked deprecated here}}
53 i
= 12; // expected-warning {{'i' is deprecated: this is the message}}
56 // Ensure that deprecated only accepts one argument, not the replacement
57 // argument supported as a GNU extension.
58 [[deprecated("message", "replacement not supported")]] void test5(void); // expected-error {{'deprecated' attribute takes no more than 1 argument}}