Index: include/clang/Basic/Attr.td =================================================================== --- include/clang/Basic/Attr.td +++ include/clang/Basic/Attr.td @@ -1149,7 +1149,7 @@ let Documentation = [NoSplitStackDocs]; } -def NonNull : InheritableAttr { +def NonNull : InheritableParamAttr { let Spellings = [GCC<"nonnull">]; let Subjects = SubjectList<[ObjCMethod, HasFunctionProto, ParmVar], WarnDiag, "ExpectedFunctionMethodOrParameter">; Index: test/Sema/nonnull.c =================================================================== --- test/Sema/nonnull.c +++ test/Sema/nonnull.c @@ -111,7 +111,7 @@ return 0; } else { return *pointer; - } + } set_param_to_null(&pointer); if (!pointer) @@ -167,3 +167,10 @@ int and_again = !returns_nonnull_whee(); // expected-warning {{nonnull function call 'returns_nonnull_whee()' will evaluate to 'true' on first encounter}} and_again = !returns_nonnull_whee(); // expected-warning {{nonnull function call 'returns_nonnull_whee()' will evaluate to 'true' on first encounter}} } + +void pr30828(char *p __attribute__((nonnull))); +void pr30828(char *p) {} + +void call_pr30828() { + pr30828(0); // expected-warning {{null passed to a callee that requires a non-null argument}} +}