[clang-cl] Ignore /Wv and /Wv:17 flags
[llvm-project.git] / clang / test / Analysis / null-deref-path-notes.c
blob6d4a4aa4ef96117ca072e26c20f30de725280167
1 // RUN: %clang_analyze_cc1 -w -x c -analyzer-checker=core,unix -analyzer-output=text -verify %s
3 // Avoid the crash when finding the expression for tracking the origins
4 // of the null pointer for path notes.
5 void pr34373(void) {
6 int *a = 0; // expected-note{{'a' initialized to a null pointer value}}
7 (a + 0)[0]; // expected-warning{{Array access results in a null pointer dereference}}
8 // expected-note@-1{{Array access results in a null pointer dereference}}
11 typedef __typeof(sizeof(int)) size_t;
12 void *memcpy(void *dest, const void *src, unsigned long count);
14 void f1(char *source) {
15 char *destination = 0; // expected-note{{'destination' initialized to a null pointer value}}
16 memcpy(destination + 0, source, 10); // expected-warning{{Null pointer passed as 1st argument to memory copy function}}
17 // expected-note@-1{{Null pointer passed as 1st argument to memory copy function}}
20 void f2(char *source) {
21 char *destination = 0; // expected-note{{'destination' initialized to a null pointer value}}
22 memcpy(destination - 0, source, 10); // expected-warning{{Null pointer passed as 1st argument to memory copy function}}
23 // expected-note@-1{{Null pointer passed as 1st argument to memory copy function}}
26 void f3(char *source) {
27 char *destination = 0; // expected-note{{'destination' initialized to a null pointer value}}
28 destination = destination + 0; // expected-note{{Null pointer value stored to 'destination'}}
29 memcpy(destination, source, 10); // expected-warning{{Null pointer passed as 1st argument to memory copy function}}
30 // expected-note@-1{{Null pointer passed as 1st argument to memory copy function}}
33 void f4(char *source) {
34 char *destination = 0; // expected-note{{'destination' initialized to a null pointer value}}
35 destination = destination - 0; // expected-note{{Null pointer value stored to 'destination'}}
36 memcpy(destination, source, 10); // expected-warning{{Null pointer passed as 1st argument to memory copy function}}
37 // expected-note@-1{{Null pointer passed as 1st argument to memory copy function}}
40 void f5(char *source) {
41 char *destination1 = 0; // expected-note{{'destination1' initialized to a null pointer value}}
42 char *destination2 = destination1 + 0; // expected-note{{'destination2' initialized to a null pointer value}}
43 memcpy(destination2, source, 10); // expected-warning{{Null pointer passed as 1st argument to memory copy function}}
44 // expected-note@-1{{Null pointer passed as 1st argument to memory copy function}}
47 void f6(char *source) {
48 char *destination1 = 0; // expected-note{{'destination1' initialized to a null pointer value}}
49 char *destination2 = destination1 - 0; // expected-note{{'destination2' initialized to a null pointer value}}
50 memcpy(destination2, source, 10); // expected-warning{{Null pointer passed as 1st argument to memory copy function}}
51 // expected-note@-1{{Null pointer passed as 1st argument to memory copy function}}