diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp index c769b856cd..cacc846028 100644 --- a/lib/Sema/SemaExprObjC.cpp +++ b/lib/Sema/SemaExprObjC.cpp @@ -324,6 +324,12 @@ bool Sema::CheckMessageArgumentTypes(Expr **Args, unsigned NumArgs, Args[NumArgs-1]->getLocEnd()); } } + // diagnose nonnull arguments. + for (specific_attr_iterator + i = Method->specific_attr_begin(), + e = Method->specific_attr_end(); i != e; ++i) { + CheckNonNullArguments(*i, Args, lbrac); + } DiagnoseSentinelCalls(Method, lbrac, Args, NumArgs); return IsError; diff --git a/test/SemaObjC/nonnull.m b/test/SemaObjC/nonnull.m index 6c45d97b06..76c6ffa229 100644 --- a/test/SemaObjC/nonnull.m +++ b/test/SemaObjC/nonnull.m @@ -67,3 +67,30 @@ void func6(dispatch_object_t _head) { _dispatch_queue_push_list(_head._do); // no warning } +// rdar://9287695 +#define NULL (void*)0 + +@interface NSObject +- (void)doSomethingWithNonNullPointer:(void *)ptr :(int)iarg : (void*)ptr1 __attribute__((nonnull(1, 3))); ++ (void)doSomethingClassyWithNonNullPointer:(void *)ptr __attribute__((nonnull(1))); +@end + +extern void DoSomethingNotNull(void *db) __attribute__((nonnull(1))); + +@interface IMP +{ + void * vp; +} +@end + +@implementation IMP +- (void) Meth { + NSObject *object; + [object doSomethingWithNonNullPointer:NULL:1:NULL]; // expected-warning 2 {{null passed to a callee which requires a non-null argument}} + [object doSomethingWithNonNullPointer:vp:1:NULL]; // expected-warning {{null passed to a callee which requires a non-null argument}} + [NSObject doSomethingClassyWithNonNullPointer:NULL]; // expected-warning {{null passed to a callee which requires a non-null argument}} + DoSomethingNotNull(NULL); // expected-warning {{null passed to a callee which requires a non-null argument}} + [object doSomethingWithNonNullPointer:vp:1:vp]; +} +@end +