1 // RUN: %clang_cc1 -fsyntax-only -verify %s -Wunused-function
3 /// We allow 'retain' on non-ELF targets because 'retain' is often used together
4 /// with 'used'. 'used' has GC root semantics on macOS and Windows. We want
5 /// users to just write retain,used and don't need to dispatch on binary formats.
7 extern char test1
[] __attribute__((retain
)); // expected-warning {{'retain' attribute ignored on a non-definition declaration}}
8 extern const char test2
[] __attribute__((retain
)); // expected-warning {{'retain' attribute ignored on a non-definition declaration}}
9 const char test3
[] __attribute__((retain
)) = "";
11 struct __attribute__((retain
)) s
{ // expected-warning {{'retain' attribute only applies to variables with non-local storage, functions, and Objective-C methods}}
15 static int a
__attribute__((retain
));
16 int b
__attribute__((retain
)); // expected-warning {{'retain' attribute only applies to variables with non-local storage, functions, and Objective-C methods}}
21 __attribute__((retain
,used
)) static void f0(void) {}
22 __attribute__((retain
)) static void f1(void) {} // expected-warning {{unused function 'f1'}}
23 __attribute__((retain
)) void f2(void) {}
25 /// Test attribute merging.
27 int tentative
__attribute__((retain
));