xref: /minix3/external/bsd/llvm/dist/clang/test/SemaCXX/nonnull.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s
2*0a6a1f1dSLionel Sambuc 
3*0a6a1f1dSLionel Sambuc template<int I>
4*0a6a1f1dSLionel Sambuc struct TS {
5*0a6a1f1dSLionel Sambuc   __attribute__((returns_nonnull))
value_dependentTS6*0a6a1f1dSLionel Sambuc   void *value_dependent(void) {
7*0a6a1f1dSLionel Sambuc     return I; // no-warning
8*0a6a1f1dSLionel Sambuc   }
9*0a6a1f1dSLionel Sambuc 
10*0a6a1f1dSLionel Sambuc   __attribute__((returns_nonnull))
value_independentTS11*0a6a1f1dSLionel Sambuc   void *value_independent(void) {
12*0a6a1f1dSLionel Sambuc     return 0; // expected-warning {{null returned from function that requires a non-null return value}}
13*0a6a1f1dSLionel Sambuc   }
14*0a6a1f1dSLionel Sambuc };
15*0a6a1f1dSLionel Sambuc 
16*0a6a1f1dSLionel Sambuc namespace Template {
17*0a6a1f1dSLionel Sambuc   template<typename T> __attribute__((nonnull)) void f(T t);
g()18*0a6a1f1dSLionel Sambuc   void g() { f((void*)0); } // expected-warning {{null passed to a callee that requires a non-null argument}}
h()19*0a6a1f1dSLionel Sambuc   void h() { f(0); }
20*0a6a1f1dSLionel Sambuc }
21