1// RUN: %clang_cc1 -w -fblocks -analyze -analyzer-checker=core,deadcode,alpha.core,debug.ExprInspection -verify %s 2 3void *malloc(unsigned long); 4void clang_analyzer_warnIfReached(); 5 6void test_static_from_block() { 7 static int *x; 8 ^{ 9 *x; // no-warning 10 }; 11} 12 13void test_static_within_block() { 14 ^{ 15 static int *x; 16 *x; // expected-warning{{Dereference of null pointer}} 17 }; 18} 19 20void test_static_control_flow(int y) { 21 static int *x; 22 if (x) { 23 // FIXME: Should be reachable. 24 clang_analyzer_warnIfReached(); // no-warning 25 } 26 if (y) { 27 // We are not sure if this branch is possible, because the developer 28 // may argue that function is always called with y == 1 for the first time. 29 // In this case, we can only advise the developer to add assertions 30 // for suppressing such path. 31 *x; // expected-warning{{Dereference of null pointer}} 32 } else { 33 x = malloc(1); 34 } 35} 36