diff options
| author | John McCall <rjmccall@apple.com> | 2015-10-27 04:54:50 +0000 |
|---|---|---|
| committer | John McCall <rjmccall@apple.com> | 2015-10-27 04:54:50 +0000 |
| commit | b61e14e5962a2b881db3b7515e8c4f6f762fa0f2 (patch) | |
| tree | 535f9505a6499d7a3da0a52f714fb3699730f527 /clang/test/SemaObjC/mrc-no-weak.m | |
| parent | c692688cbd6e1f73426ebf3d660d05677603427d (diff) | |
| download | bcm5719-llvm-b61e14e5962a2b881db3b7515e8c4f6f762fa0f2.tar.gz bcm5719-llvm-b61e14e5962a2b881db3b7515e8c4f6f762fa0f2.zip | |
Be more conservative about diagnosing "incorrect" uses of __weak:
allow them to be written in certain kinds of user declaration and
diagnose on the use-site instead.
Also, improve and fix some diagnostics relating to __weak and
properties.
rdar://23228631
llvm-svn: 251384
Diffstat (limited to 'clang/test/SemaObjC/mrc-no-weak.m')
| -rw-r--r-- | clang/test/SemaObjC/mrc-no-weak.m | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/clang/test/SemaObjC/mrc-no-weak.m b/clang/test/SemaObjC/mrc-no-weak.m new file mode 100644 index 00000000000..2fe2d33d505 --- /dev/null +++ b/clang/test/SemaObjC/mrc-no-weak.m @@ -0,0 +1,54 @@ +// RUN: %clang_cc1 -fobjc-runtime=macosx-10.8 -fsyntax-only -verify %s + +__attribute__((objc_root_class)) +@interface Root @end + +// These should not get diagnosed immediately. +@interface A : Root { + __weak id x; +} +@property __weak id y; +@end + +// Diagnostic goes on the ivar if it's explicit. +@interface B : Root { + __weak id x; // expected-error {{cannot create __weak reference in file using manual reference counting}} +} +@property __weak id x; +@end +@implementation B +@synthesize x; +@end + +// Otherwise, it goes with the @synthesize. +@interface C : Root +@property __weak id x; // expected-note {{property declared here}} +@end +@implementation C +@synthesize x; // expected-error {{cannot synthesize weak property in file using manual reference counting}} +@end + +@interface D : Root +@property __weak id x; // expected-note {{property declared here}} +@end +@implementation D // expected-error {{cannot synthesize weak property in file using manual reference counting}} +@end + +@interface E : Root { +@public + __weak id x; // expected-note 2 {{unsupported declaration here}} +} +@end + +void testE(E *e) { + id x = e->x; // expected-error {{'x' is unavailable: cannot use weak references in file using manual reference counting}} + e->x = x; // expected-error {{'x' is unavailable: cannot use weak references in file using manual reference counting}} +} + +@interface F : Root +@property (weak) id x; +@end + +void testF(F *f) { + id x = f.x; +} |

