1 // RUN: %clang_cc1 %s -verify -fsyntax-only
2 // RUN: %clang_cc1 %s -std=c89 -verify -fsyntax-only
3 // RUN: %clang_cc1 %s -std=c99 -verify -fsyntax-only
5 int f(void) __attribute__((deprecated
)); // expected-note 2 {{'f' has been explicitly marked deprecated here}}
6 void g(void) __attribute__((deprecated
));// expected-note {{'g' has been explicitly marked deprecated here}}
9 extern int var
__attribute__((deprecated
)); // expected-note 2 {{'var' has been explicitly marked deprecated here}}
12 int (*ptr
)(void) = f
; // expected-warning {{'f' is deprecated}}
13 f(); // expected-warning {{'f' is deprecated}}
15 // test if attributes propagate to functions
16 g(); // expected-warning {{'g' is deprecated}}
18 return var
; // expected-warning {{'var' is deprecated}}
21 // test if attributes propagate to variables
24 return var
; // expected-warning {{'var' is deprecated}}
27 int old_fn(void) __attribute__ ((deprecated
));// expected-note {{'old_fn' has been explicitly marked deprecated here}}
29 int (*fn_ptr
)(void) = old_fn
; // expected-warning {{'old_fn' is deprecated}}
32 return old_fn()+1; // no warning, deprecated functions can use deprecated symbols.
37 int x
__attribute__((deprecated
)); // expected-note 3 {{'x' has been explicitly marked deprecated here}}
40 void test1(struct foo
*F
) {
41 ++F
->x
; // expected-warning {{'x' is deprecated}}
42 struct foo f1
= { .x
= 17 }; // expected-warning {{'x' is deprecated}}
43 struct foo f2
= { 17 }; // expected-warning {{'x' is deprecated}}
46 typedef struct foo foo_dep
__attribute__((deprecated
)); // expected-note 12 {{'foo_dep' has been explicitly marked deprecated here}}
47 foo_dep
*test2
; // expected-warning {{'foo_dep' is deprecated}}
49 struct __attribute__((deprecated
, // expected-note 2 {{'bar_dep' has been explicitly marked deprecated here}}
50 invalid_attribute
)) bar_dep
; // expected-warning {{unknown attribute 'invalid_attribute' ignored}}
52 struct bar_dep
*test3
; // expected-warning {{'bar_dep' is deprecated}}
55 // These should not warn because the actually declaration itself is deprecated.
57 foo_dep
*test4
__attribute__((deprecated
));
58 struct bar_dep
*test5
__attribute__((deprecated
));
60 typedef foo_dep
test6(struct bar_dep
*); // expected-warning {{'foo_dep' is deprecated}} \
61 // expected-warning {{'bar_dep' is deprecated}}
62 typedef foo_dep
test7(struct bar_dep
*) __attribute__((deprecated
));
65 p
+= sizeof(foo_dep
); // expected-warning {{'foo_dep' is deprecated}}
67 foo_dep
*ptr
; // expected-warning {{'foo_dep' is deprecated}}
68 ptr
= (foo_dep
*) p
; // expected-warning {{'foo_dep' is deprecated}}
70 int func(foo_dep
*foo
); // expected-warning {{'foo_dep' is deprecated}}
74 foo_dep
*test9(void) __attribute__((deprecated
));
75 foo_dep
*test9(void) {
76 void* myalloc(unsigned long);
80 myalloc(sizeof(foo_dep
));
84 void test10(void) __attribute__((deprecated
));
86 if (sizeof(foo_dep
) == sizeof(void*)) {
88 foo_dep
*localfunc(void);
92 char test11
[sizeof(foo_dep
)] __attribute__((deprecated
));
93 char test12
[sizeof(foo_dep
)]; // expected-warning {{'foo_dep' is deprecated}}
95 int test13(foo_dep
*foo
) __attribute__((deprecated
));
96 int test14(foo_dep
*foo
); // expected-warning {{'foo_dep' is deprecated}}
98 unsigned long test15
= sizeof(foo_dep
); // expected-warning {{'foo_dep' is deprecated}}
99 unsigned long test16
__attribute__((deprecated
))
102 foo_dep test17
, // expected-warning {{'foo_dep' is deprecated}}
103 test18
__attribute__((deprecated
)),
106 // rdar://problem/8518751
107 enum __attribute__((deprecated
)) Test20
{ // expected-note 2 {{'Test20' has been explicitly marked deprecated here}}
108 test20_a
__attribute__((deprecated
)), // expected-note {{'test20_a' has been explicitly marked deprecated here}}
112 enum Test20 f
; // expected-warning {{'Test20' is deprecated}}
113 f
= test20_a
; // expected-warning {{'test20_a' is deprecated}}
114 f
= test20_b
; // expected-warning {{'test20_b' is deprecated}}
117 char test21
[__has_feature(attribute_deprecated_with_message
) ? 1 : -1];
120 foo_dep a
__attribute((deprecated
));
121 foo_dep b
; // expected-warning {{'foo_dep' is deprecated}}
122 foo_dep c
, d
__attribute((deprecated
)); // expected-warning {{'foo_dep' is deprecated}}
123 __attribute((deprecated
)) foo_dep e
, f
;
126 typedef int test23_ty
__attribute((deprecated
));
127 // Redefining a typedef is a C11 feature.
128 #if __STDC_VERSION__ <= 199901L
129 // expected-note@-3 {{'test23_ty' has been explicitly marked deprecated here}}
131 // expected-note@-5 {{'test23_ty' has been explicitly marked deprecated here}}
132 typedef int test23_ty
;
134 test23_ty test23_v
; // expected-warning {{'test23_ty' is deprecated}}