[clang-cl] Ignore /Wv and /Wv:17 flags
[llvm-project.git] / clang / test / Analysis / cxx-crashes.cpp
blobf8234c99ef5ed48b4cbcbe295698c1c26ebcab51
1 // RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,debug.ExprInspection -verify %s
2 // REQUIRES: LP64
4 void clang_analyzer_eval(bool);
6 int f1(char *dst) {
7 char *p = dst + 4;
8 char *q = dst + 3;
9 return !(q >= p);
12 long f2(char *c) {
13 return long(c) & 1;
16 bool f3() {
17 return !false;
20 void *f4(int* w) {
21 return reinterpret_cast<void*&>(w);
24 namespace {
26 struct A { };
27 struct B {
28 operator A() { return A(); }
31 A f(char *dst) {
32 B b;
33 return b;
38 namespace {
40 struct S {
41 void *p;
44 void *f(S* w) {
45 return &reinterpret_cast<void*&>(*w);
50 namespace {
52 struct C {
53 void *p;
54 static void f();
57 void C::f() { }
62 void vla(int n) {
63 int nums[n];
64 nums[0] = 1;
65 clang_analyzer_eval(nums[0] == 1); // expected-warning{{TRUE}}
67 // This used to fail with MallocChecker on, and /only/ in C++ mode.
68 // This struct is POD, though, so it should be fine to put it in a VLA.
69 struct { int x; } structs[n];
70 structs[0].x = 1;
71 clang_analyzer_eval(structs[0].x == 1); // expected-warning{{TRUE}}
74 void useIntArray(int []);
75 void testIntArrayLiteral() {
76 useIntArray((int []){ 1, 2, 3 });