blob: 32d7b5200ef33d648fe8663ba3e2969c4dc62a16 [file] [log] [blame]
// RUN: %clang_analyze_cc1 -analyzer-checker=core,apiModeling.TrustReturnsNonnull -verify %s
int *foo() __attribute__((returns_nonnull));
int *foo_no_attribute();
int test_foo() {
int *x = foo();
if (x) {}
return *x; // no-warning
}
int test_foo_no_attribute() {
int *x = foo_no_attribute();
if (x) {}
return *x; // expected-warning{{Dereference of null pointer}}
}
void test(void *(*f)(void)) {
f(); // Shouldn't crash compiler
}