diff options
Diffstat (limited to 'test/SemaObjC/unused.m')
-rw-r--r-- | test/SemaObjC/unused.m | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/SemaObjC/unused.m b/test/SemaObjC/unused.m index 3fd1cf04673f4..6ea3fe8e00ab3 100644 --- a/test/SemaObjC/unused.m +++ b/test/SemaObjC/unused.m @@ -72,3 +72,35 @@ static NSString *x = @"hi"; // expected-warning {{unused variable 'x'}} - (void) b {} - (void) a { [self b]; } @end + +// Test that objc_precise_lifetime suppresses +// unused variable warnings. +extern void rdar15596883_foo(void); +void rdar15596883(id x) { + __attribute__((objc_precise_lifetime)) id y = x; // no-warning + rdar15596883_foo(); +} + +@interface PropertyObject : NSObject +@property int length; +@end + +@protocol P +@property int property; +@end + +void test3(PropertyObject *o) +{ + [o length]; // expected-warning {{property access result unused - getters should not be used for side effects}} + (void)[o length]; +} + +void test4(id o) +{ + [o length]; // No warning. +} + +void test5(id <P> p) +{ + [p property]; // expected-warning {{property access result unused - getters should not be used for side effects}} +} |