[clang-cl] Ignore /Wv and /Wv:17 flags
[llvm-project.git] / clang / test / Analysis / undef-buffers.c
blobb5058dc0ac914531e23199f3ba69d40f32782c33
1 // RUN: %clang_analyze_cc1 -analyzer-store=region -verify %s \
2 // RUN: -analyzer-checker=core \
3 // RUN: -analyzer-checker=unix \
4 // RUN: -analyzer-checker=core.uninitialized \
5 // RUN: -analyzer-config unix.DynamicMemoryModeling:Optimistic=true
7 typedef __typeof(sizeof(int)) size_t;
8 void *malloc(size_t);
9 void free(void *);
11 char stackBased1 (void) {
12 char buf[2];
13 buf[0] = 'a';
14 return buf[1]; // expected-warning{{Undefined}}
17 char stackBased2 (void) {
18 char buf[2];
19 buf[1] = 'a';
20 return buf[0]; // expected-warning{{Undefined}}
23 // Exercise the conditional visitor. Radar://10105448
24 char stackBased3 (int *x) {
25 char buf[2];
26 int *y;
27 buf[0] = 'a';
28 if (!(y = x)) {
29 return buf[1]; // expected-warning{{Undefined}}
31 return buf[0];
34 char heapBased1 (void) {
35 char *buf = malloc(2);
36 buf[0] = 'a';
37 char result = buf[1]; // expected-warning{{undefined}}
38 free(buf);
39 return result;
42 char heapBased2 (void) {
43 char *buf = malloc(2);
44 buf[1] = 'a';
45 char result = buf[0]; // expected-warning{{undefined}}
46 free(buf);
47 return result;