blob: 303dce0d8752b2a50d81e0c3c31acd488895ff74 [file] [log] [blame]
John McCalled14ad22011-03-08 04:17:03 +00001// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify %s
Anders Carlssonc7c20702008-08-24 16:33:25 +00002static id __attribute((objc_gc(weak))) a;
3static id __attribute((objc_gc(strong))) b;
4
Aaron Ballman3bf758c2013-07-30 01:31:03 +00005static id __attribute((objc_gc())) c; // expected-error{{'objc_gc' attribute requires a string}}
6static id __attribute((objc_gc(123))) d; // expected-error{{'objc_gc' attribute requires a string}}
Aaron Ballmanb7243382013-07-23 19:30:11 +00007static id __attribute((objc_gc(foo, 456))) e; // expected-error{{'objc_gc' attribute takes one argument}}
Anders Carlssonc7c20702008-08-24 16:33:25 +00008static id __attribute((objc_gc(hello))) f; // expected-warning{{'objc_gc' attribute argument not supported: 'hello'}}
John McCalled14ad22011-03-08 04:17:03 +00009
10static int __attribute__((objc_gc(weak))) g; // expected-warning {{'objc_gc' only applies to pointer types; type here is 'int'}}
11
John McCall460ce582015-10-22 18:38:17 +000012static __weak int h; // expected-warning {{'__weak' only applies to Objective-C object or block pointer types; type here is 'int'}}
John McCall462c0552011-03-08 07:59:04 +000013
14// TODO: it would be great if this reported as __weak
15#define WEAK __weak
John McCall460ce582015-10-22 18:38:17 +000016static WEAK int h; // expected-warning {{'objc_ownership' only applies to Objective-C object or block pointer types; type here is 'int'}}
John McCall462c0552011-03-08 07:59:04 +000017
John McCall460ce582015-10-22 18:38:17 +000018/* expected-warning {{'__weak' only applies to Objective-C object or block pointer types; type here is 'int'}}*/ static __we\
John McCall462c0552011-03-08 07:59:04 +000019ak int i;
John McCall78535952011-03-26 02:56:45 +000020
21// rdar://problem/9126213
22void test2(id __attribute((objc_gc(strong))) *strong,
23 id __attribute((objc_gc(weak))) *weak) {
24 void *opaque;
25 opaque = strong;
26 strong = opaque;
27
28 opaque = weak;
29 weak = opaque;
30}