blob: 19d6642eb553a287ad36d69e8991b5cd8651e5e7 [file] [log] [blame]
Chandler Carruth07d7e7a2010-11-16 08:35:43 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
2struct S {
3 static void f(const char*, const char*) __attribute__((nonnull(1)));
4
5 // GCC has a hidden 'this' argument in member functions, so the middle
6 // argument is the one that must not be null.
7 void g(const char*, const char*, const char*) __attribute__((nonnull(3)));
8
9 void h(const char*) __attribute__((nonnull(1))); // \
10 expected-error{{invalid for the implicit this argument}}
11};
12
13void test(S s) {
14 s.f(0, ""); // expected-warning{{null passed}}
15 s.f("", 0);
16 s.g("", 0, ""); // expected-warning{{null passed}}
17 s.g(0, "", 0);
18}
Douglas Gregorde436322010-12-15 15:41:46 +000019
20namespace rdar8769025 {
21 __attribute__((nonnull)) void f0(int *&p);
22 __attribute__((nonnull)) void f1(int * const &p);
23 __attribute__((nonnull(2))) void f2(int i, int * const &p);
24
25 void test_f1() {
26 f1(0); // expected-warning{{null passed to a callee which requires a non-null argument}}
27 f2(0, 0); // expected-warning{{null passed to a callee which requires a non-null argument}}
28 }
29}