| 1 |
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify %s |
| 2 |
static id __attribute((objc_gc(weak))) a; |
| 3 |
static id __attribute((objc_gc(strong))) b; |
| 4 |
|
| 5 |
static id __attribute((objc_gc())) c; // expected-error{{'objc_gc' attribute requires a string}} |
| 6 |
static id __attribute((objc_gc(123))) d; // expected-error{{'objc_gc' attribute requires a string}} |
| 7 |
static id __attribute((objc_gc(foo, 456))) e; // expected-error{{'objc_gc' attribute takes one argument}} |
| 8 |
static id __attribute((objc_gc(hello))) f; // expected-warning{{'objc_gc' attribute argument not supported: 'hello'}} |
| 9 |
|
| 10 |
static int __attribute__((objc_gc(weak))) g; // expected-warning {{'objc_gc' only applies to pointer types; type here is 'int'}} |
| 11 |
|
| 12 |
static __weak int h; // expected-warning {{'__weak' only applies to Objective-C object or block pointer types; type here is 'int'}} |
| 13 |
|
| 14 |
// TODO: it would be great if this reported as __weak |
| 15 |
#define WEAK __weak |
| 16 |
static WEAK int h; // expected-warning {{'objc_ownership' only applies to Objective-C object or block pointer types; type here is 'int'}} |
| 17 |
|
| 18 |
/* expected-warning {{'__weak' only applies to Objective-C object or block pointer types; type here is 'int'}}*/ static __we\ |
| 19 |
ak int i; |
| 20 |
|
| 21 |
static id [[clang::objc_gc(weak)]] j; |
| 22 |
[[clang::objc_gc(weak)]] static id k; // expected-warning {{applying attribute 'clang::objc_gc' to a declaration is deprecated; apply it to the type instead}} |
| 23 |
static id l [[clang::objc_gc(weak)]]; // expected-warning {{applying attribute 'clang::objc_gc' to a declaration is deprecated; apply it to the type instead}} |
| 24 |
|
| 25 |
void test2(id __attribute((objc_gc(strong))) *strong, |
| 26 |
id __attribute((objc_gc(weak))) *weak) { |
| 27 |
void *opaque; |
| 28 |
opaque = strong; |
| 29 |
strong = opaque; |
| 30 |
|
| 31 |
opaque = weak; |
| 32 |
weak = opaque; |
| 33 |
} |