diff options
Diffstat (limited to 'test/SemaObjC/nonnull.m')
-rw-r--r-- | test/SemaObjC/nonnull.m | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/test/SemaObjC/nonnull.m b/test/SemaObjC/nonnull.m index 15fee74..6c45d97 100644 --- a/test/SemaObjC/nonnull.m +++ b/test/SemaObjC/nonnull.m @@ -1,8 +1,11 @@ +#include "nonnull.h" + // RUN: %clang_cc1 -fblocks -fsyntax-only -verify %s @class NSObject; -int f1(int x) __attribute__((nonnull)); // expected-warning{{'nonnull' attribute applied to function with no pointer arguments}} +NONNULL_ATTR +int f1(int x); // no warning int f2(int *x) __attribute__ ((nonnull (1))); int f3(int *x) __attribute__ ((nonnull (0))); // expected-error {{'nonnull' attribute parameter 1 is out of bounds}} int f4(int *x, int *y) __attribute__ ((nonnull (1,2))); @@ -44,4 +47,23 @@ foo (int i1, int i2, int i3, void (^cp1)(), void (^cp2)(), void (^cp3)()) func7((NSObject*) 0); // no-warning } -void func5(int) __attribute__((nonnull)); // expected-warning{{'nonnull' attribute applied to function with no pointer arguments}} +void func5(int) NONNULL_ATTR; // no warning + +// rdar://6857843 +struct dispatch_object_s { + int x; +}; + +typedef union { + long first; + struct dispatch_object_s *_do; +} dispatch_object_t __attribute__((transparent_union)); + +__attribute__((nonnull)) +void _dispatch_queue_push_list(dispatch_object_t _head); // no warning + +void func6(dispatch_object_t _head) { + _dispatch_queue_push_list(0); // expected-warning {{null passed to a callee which requires a non-null argument}} + _dispatch_queue_push_list(_head._do); // no warning +} + |