func.c revision 7453624b98817f06d28ed2abe39c98805cfec623
1// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core,debug.ExprInspection -analyzer-store=region -verify %s 2 3void clang_analyzer_eval(int); 4 5void f(void) { 6 void (*p)(void); 7 p = f; 8 p = &f; 9 p(); 10 (*p)(); 11} 12 13void g(void (*fp)(void)); 14 15void f2() { 16 g(f); 17} 18 19void f3(void (*f)(void), void (*g)(void)) { 20 clang_analyzer_eval(!f); // expected-warning{{UNKNOWN}} 21 f(); 22 clang_analyzer_eval(!f); // expected-warning{{FALSE}} 23 24 clang_analyzer_eval(!g); // expected-warning{{UNKNOWN}} 25 (*g)(); 26 clang_analyzer_eval(!g); // expected-warning{{FALSE}} 27} 28 29void nullFunctionPointerConstant() { 30 void (*f)(void) = 0; 31 f(); // expected-warning{{Called function pointer is null}} 32 clang_analyzer_eval(0); // no-warning 33} 34 35void nullFunctionPointerConstraint(void (*f)(void)) { 36 if (f) 37 return; 38 f(); // expected-warning{{Called function pointer is null}} 39 clang_analyzer_eval(0); // no-warning 40} 41