attr-nonnull.cpp revision 07d7e7a6b10f798459f350b792713db2fb3e9365
1// 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} 19