[PATCH] D26800: [Sema] Make __attribute__((notnull)) inheritable through function parameters
Matt Bettinson via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 9 11:51:11 PST 2017
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">;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26800.91204.patch
Type: text/x-patch
Size: 1313 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170309/bb168e50/attachment.bin>
More information about the cfe-commits
mailing list