xref: /llvm-project/clang/test/SemaObjC/nullable-weak-property.m (revision 0f1c1be1968076d6f96f8a7bcc4a15cf195ecd97)
1// RUN: %clang_cc1 -fobjc-arc -fobjc-runtime-has-weak -Wnullable-to-nonnull-conversion %s -verify
2
3@interface NSObject @end
4
5@class NSFoo;
6void foo (NSFoo * _Nonnull);
7
8@interface NSBar : NSObject
9@property(weak) NSFoo *property1;
10@end
11
12#pragma clang assume_nonnull begin
13@interface NSBar ()
14@property(weak) NSFoo *property2;
15@end
16
17#pragma clang assume_nonnull end
18
19@implementation NSBar
20- (void) Meth {
21   foo (self.property1); // no warning because nothing is inferred
22   foo (self.property2); // expected-warning {{implicit conversion from nullable pointer 'NSFoo * _Nullable' to non-nullable pointer type 'NSFoo * _Nonnull'}}
23}
24@end
25