1 // RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core -verify %s
2 
3 void nonnull [[gnu::nonnull]] (int *q);
4 
f1(int * p)5 void f1(int *p) {
6   if (p)
7     return;
8   nonnull(p); //expected-warning{{nonnull}}
9 }
10 
f2(int * p)11 void f2(int *p) {
12   if (p)
13     return;
14   auto lambda = [](int *q) __attribute__((nonnull)){};
15   lambda(p); //expected-warning{{nonnull}}
16 }
17 
18 template <class... ARGS>
19 void variadicNonnull(ARGS... args) __attribute__((nonnull));
20 
f3(int a,float b,int * p)21 void f3(int a, float b, int *p) {
22   if (p)
23     return;
24   variadicNonnull(a, b, p); //expected-warning{{nonnull}}
25 }
26 
27 int globalVar = 15;
28 void moreParamsThanArgs [[gnu::nonnull(2, 4)]] (int a, int *p, int b = 42, int *q = &globalVar);
29 
f4(int a,int * p)30 void f4(int a, int *p) {
31   if (p)
32     return;
33   moreParamsThanArgs(a, p); //expected-warning{{nonnull}}
34 }
35