| 1 |
// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime-has-weak -fobjc-weak -fblocks -Wno-objc-root-class -std=c++98 -Wno-c++0x-extensions -verify %s |
| 2 |
|
| 3 |
@interface AnObject |
| 4 |
@property(weak) id value; |
| 5 |
@end |
| 6 |
|
| 7 |
__attribute__((objc_arc_weak_reference_unavailable)) |
| 8 |
@interface NOWEAK : AnObject // expected-note 2 {{class is declared here}} |
| 9 |
@end |
| 10 |
|
| 11 |
struct S { |
| 12 |
__weak id a; // expected-note {{because type 'S' has a member with __weak ownership}} |
| 13 |
}; |
| 14 |
|
| 15 |
union U { |
| 16 |
__weak id a; |
| 17 |
S b; // expected-error {{union member 'b' has a non-trivial copy constructor}} |
| 18 |
}; |
| 19 |
|
| 20 |
void testCast(AnObject *o) { |
| 21 |
__weak id a = reinterpret_cast<__weak NOWEAK *>(o); // expected-error {{class is incompatible with __weak references}} \ |
| 22 |
// expected-error {{explicit ownership qualifier on cast result has no effect}} \ |
| 23 |
// expected-error {{assignment of a weak-unavailable object to a __weak object}} |
| 24 |
|
| 25 |
__weak id b = static_cast<__weak NOWEAK *>(o); // expected-error {{class is incompatible with __weak references}} \ |
| 26 |
// expected-error {{explicit ownership qualifier on cast result has no effect}} \ |
| 27 |
// expected-error {{assignment of a weak-unavailable object to a __weak object}} |
| 28 |
} |