blob: a4955ca0a45e41b753975f925111dcd891131e3f [file] [log] [blame]
Jordan Rose682b3162012-07-02 19:28:21 +00001// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify %s
2
3@interface MyObject
4- (void)takePointer:(void *)ptr __attribute__((nonnull(1)));
Ted Kremenekf0ae7d02014-01-17 07:15:35 +00005- (void)takePointerArg:(void *)__attribute__((nonnull)) ptr;
6
Jordan Rose682b3162012-07-02 19:28:21 +00007@end
8
9void testNonNullMethod(int *p, MyObject *obj) {
10 if (p)
11 return;
12 [obj takePointer:p]; // expected-warning{{nonnull}}
13}
14
15
16@interface Subclass : MyObject
17// [[nonnull]] is an inherited attribute.
18- (void)takePointer:(void *)ptr;
19@end
20
21void testSubclass(int *p, Subclass *obj) {
22 if (p)
23 return;
24 [obj takePointer:p]; // expected-warning{{nonnull}}
25}
Ted Kremenekf0ae7d02014-01-17 07:15:35 +000026
27void testSubclassArg(int *p, Subclass *obj) {
28 if (p)
29 return;
30 [obj takePointerArg:p]; // expected-warning{{nonnull}}
31}
32