]> granicus.if.org Git - clang/commitdiff
Allow the nonnull attribute to be inherited as a parameter in the redefinition of...
authorAaron Ballman <aaron@aaronballman.com>
Sun, 12 Mar 2017 22:30:07 +0000 (22:30 +0000)
committerAaron Ballman <aaron@aaronballman.com>
Sun, 12 Mar 2017 22:30:07 +0000 (22:30 +0000)
Patch by Matt Bettinson.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@297592 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/Attr.td
test/Sema/nonnull.c

index 53faac82c40459594b1a9e5c64b2e09a74ed4d1c..5960cca1e795bd8814f3f579e2535be221f1dc0f 100644 (file)
@@ -1149,7 +1149,7 @@ def NoSplitStack : InheritableAttr {
   let Documentation = [NoSplitStackDocs];
 }
 
-def NonNull : InheritableAttr {
+def NonNull : InheritableParamAttr {
   let Spellings = [GCC<"nonnull">];
   let Subjects = SubjectList<[ObjCMethod, HasFunctionProto, ParmVar], WarnDiag,
                              "ExpectedFunctionMethodOrParameter">;
index e98a8194dbebd3e56308045751775c174979762c..217bbb16df6000040e2728b75a97934f4df15815 100644 (file)
@@ -167,3 +167,10 @@ void returns_nonnull_warning_tests() {
   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}}
+}