// Is the function argument a pointer type?
QualType T = getFunctionOrMethodArgType(d, x);
- if (!T->isPointerType() && !T->isBlockPointerType()) {
+ if (!T->isAnyPointerType() && !T->isBlockPointerType()) {
// FIXME: Should also highlight argument in decl.
S.Diag(Attr.getLoc(), diag::err_nonnull_pointers_only)
<< "nonnull" << Ex->getSourceRange();
if (NonNullArgs.empty()) {
for (unsigned I = 0, E = getFunctionOrMethodNumArgs(d); I != E; ++I) {
QualType T = getFunctionOrMethodArgType(d, I);
- if (T->isPointerType() || T->isBlockPointerType())
+ if (T->isAnyPointerType() || T->isBlockPointerType())
NonNullArgs.push_back(I);
}
// RUN: clang-cc -fblocks -fsyntax-only -verify %s
+@class NSObject;
+
int f1(int x) __attribute__((nonnull)); // expected-warning{{'nonnull' attribute applied to function with no pointer arguments}}
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)));
int f5(int *x, int *y) __attribute__ ((nonnull (2,1)));
+int f6(NSObject *x) __attribute__ ((nonnull (1))); // no-warning
+int f7(NSObject *x) __attribute__ ((nonnull)); // no-warning
+
extern void func1 (void (^block1)(), void (^block2)(), int) __attribute__((nonnull));
func4(0, cp1); // expected-warning {{null passed to a callee which requires a non-null argument}}
func4(cp1, 0); // expected-warning {{null passed to a callee which requires a non-null argument}}
+
+ // Shouldn't these emit warnings? Clang doesn't, and neither does GCC. It
+ // seems that the checking should handle Objective-C pointers.
+ func6((NSObject*) 0); // no-warning
+ func7((NSObject*) 0); // no-warning
}