bettinson updated this revision to Diff 91204.
bettinson added a comment.

Updated the test name. Sorry for the delay!


https://reviews.llvm.org/D26800

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


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}}
+}
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}}
+}
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">;
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D26800: [Sema] Make... Matt Bettinson via Phabricator via cfe-commits

Reply via email to