From: Richard Smith Date: Wed, 27 Aug 2014 19:05:47 +0000 (+0000) Subject: Add tests for variadic functions versus attribute nonnull in the static analyzer. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=634004179fb9784061cb0407b4eac0eebbb86fcd;p=clang Add tests for variadic functions versus attribute nonnull in the static analyzer. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216577 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/Analysis/nonnull.m b/test/Analysis/nonnull.m index 0cea80b536..3de87fbdcb 100644 --- a/test/Analysis/nonnull.m +++ b/test/Analysis/nonnull.m @@ -75,3 +75,23 @@ int rdar16153464(union rdar16153464_full_ctx_t inner) 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); +}