1 // RUN: %clang_analyze_cc1 -analyzer-checker=core,unix \
2 // RUN: -analyzer-disable-checker=core.uninitialized \
5 // NOTE: These tests correspond to examples provided in documentation
6 // of [[clang::suppress]]. If you break them intentionally, it's likely that
7 // you need to update the documentation!
9 typedef __typeof(sizeof(int)) size_t;
14 return *x
; // expected-warning{{Dereference of null pointer (loaded from variable 'x')}}
20 return *x
; // null pointer dereference warning suppressed here
26 return *x
; // null pointer dereference warning suppressed here
30 int bar_initial(bool coin_flip
) {
31 int *result
= (int *)malloc(sizeof(int));
33 return 1; // There's no warning here YET, but it will show up if the other one is suppressed.
35 return *result
; // expected-warning{{Potential leak of memory pointed to by 'result'}}
38 int bar1(bool coin_flip
) {
39 __attribute__((suppress
))
40 int *result
= (int *)malloc(sizeof(int));
42 return 1; // warning about this leak path is suppressed
44 return *result
; // warning about this leak path also suppressed
47 int bar2(bool coin_flip
) {
48 int *result
= (int *)malloc(sizeof(int));
50 return 1; // expected-warning{{Potential leak of memory pointed to by 'result'}}
52 __attribute__((suppress
))
53 return *result
; // leak warning is suppressed only on this path
56 class [[clang::suppress
]] C
{
59 return *x
; // warnings suppressed in the entire class
67 return *x
; // expected-warning{{Dereference of null pointer (loaded from variable 'x')}}