brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · c8d9c81 Raw
30 lines · c
1// RUN: %clang_cc1 -fsyntax-only -verify %s -Wunused-function2 3/// We allow 'retain' on non-ELF targets because 'retain' is often used together4/// with 'used'. 'used' has GC root semantics on macOS and Windows. We want5/// users to just write retain,used and don't need to dispatch on binary formats.6 7extern char test1[] __attribute__((retain));       // expected-warning {{'retain' attribute ignored on a non-definition declaration}}8extern const char test2[] __attribute__((retain)); // expected-warning {{'retain' attribute ignored on a non-definition declaration}}9const char test3[] __attribute__((retain)) = "";10 11struct __attribute__((retain)) s { // expected-warning {{'retain' attribute only applies to variables with non-local storage, functions, and Objective-C methods}}12};13 14void foo(void) {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}}17  (void)a;18  (void)b;19}20 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) {}24 25/// Test attribute merging.26int tentative;27int tentative __attribute__((retain));28extern int tentative;29int tentative = 0;30