r216577 - Add tests for variadic functions versus attribute nonnull in the static analyzer.

Richard Smith richard-llvm at metafoo.co.uk
Wed Aug 27 12:05:47 PDT 2014


Author: rsmith
Date: Wed Aug 27 14:05:47 2014
New Revision: 216577

URL: http://llvm.org/viewvc/llvm-project?rev=216577&view=rev
Log:
Add tests for variadic functions versus attribute nonnull in the static analyzer.

Modified:
    cfe/trunk/test/Analysis/nonnull.m

Modified: cfe/trunk/test/Analysis/nonnull.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/nonnull.m?rev=216577&r1=216576&r2=216577&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/nonnull.m (original)
+++ cfe/trunk/test/Analysis/nonnull.m Wed Aug 27 14:05:47 2014
@@ -75,3 +75,23 @@ int rdar16153464(union rdar16153464_full
   rdar16153464_check(inner); // no-warning
   rdar16153464_check(0); // expected-warning{{nonnull}}
 }
+
+void testVararg(int k, void *p) {
+  extern void testVararg_check(int, ...) __attribute__((nonnull));
+  void *n = 0;
+  testVararg_check(0);
+  testVararg_check(1, p);
+  if (k == 1)
+    testVararg_check(1, n); // expected-warning{{nonnull}}
+  testVararg_check(2, p, p);
+  if (k == 2)
+    testVararg_check(2, n, p); // expected-warning{{nonnull}}
+  if (k == 3)
+    testVararg_check(2, p, n); // expected-warning{{nonnull}}
+}
+
+void testNotPtr() {
+  struct S { int a; int b; int c; } s = {};
+  extern void testNotPtr_check(struct S, int) __attribute__((nonnull(1, 2)));
+  testNotPtr_check(s, 0);
+}





More information about the cfe-commits mailing list