1 // RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s 2 3 namespace [[clang::suppress]] 4 suppressed_namespace { foo()5 int foo() { 6 int *x = 0; 7 return *x; 8 } 9 10 int foo_forward(); 11 } 12 foo_forward()13int suppressed_namespace::foo_forward() { 14 int *x = 0; 15 return *x; // expected-warning{{Dereference of null pointer (loaded from variable 'x')}} 16 } 17 18 // Another instance of the same namespace. 19 namespace suppressed_namespace { bar()20 int bar() { 21 int *x = 0; 22 return *x; // expected-warning{{Dereference of null pointer (loaded from variable 'x')}} 23 } 24 } 25 lambda()26void lambda() { 27 [[clang::suppress]] { 28 auto lam = []() { 29 int *x = 0; 30 return *x; 31 }; 32 } 33 } 34 35 class [[clang::suppress]] SuppressedClass { foo()36 int foo() { 37 int *x = 0; 38 return *x; 39 } 40 41 int bar(); 42 }; 43 bar()44int SuppressedClass::bar() { 45 int *x = 0; 46 return *x; // expected-warning{{Dereference of null pointer (loaded from variable 'x')}} 47 } 48 49 class SuppressedMethodClass { foo()50 [[clang::suppress]] int foo() { 51 int *x = 0; 52 return *x; 53 } 54 55 [[clang::suppress]] int bar1(); 56 int bar2(); 57 }; 58 bar1()59int SuppressedMethodClass::bar1() { 60 int *x = 0; 61 return *x; // expected-warning{{Dereference of null pointer (loaded from variable 'x')}} 62 } 63 64 [[clang::suppress]] bar2()65int SuppressedMethodClass::bar2() { 66 int *x = 0; 67 return *x; // no-warning 68 } 69