[clang-cl] Ignore /Wv and /Wv:17 flags
[llvm-project.git] / clang / test / Analysis / NewDeleteLeaks-PR19102.cpp
blob502db6122f5cb8f7082e3a9153d21c56585b3963
1 // RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.NewDeleteLeaks -verify %s
3 class A0 {};
5 class A1 {
6 public:
7 A1(int);
8 };
10 struct S{
11 int i;
14 class A2 {
15 public:
16 A2();
17 A2(S);
18 A2(int*);
19 A2(S*);
20 A2(S&, int);
21 A2(int, S**);
24 void test() {
25 new int; // expected-warning@+1 {{Potential memory leak}}
26 new A0; // expected-warning@+1 {{Potential memory leak}}
27 new A1(0); // expected-warning@+1 {{Potential memory leak}}
28 new A2; // expected-warning@+1 {{Potential memory leak}}
29 S s;
30 s.i = 1;
31 S* ps = new S;
32 new A2(s); // expected-warning@+1 {{Potential memory leak}}
33 new A2(&(s.i)); // expected-warning@+1 {{Potential memory leak}}
34 new A2(ps); // no warning
35 new A2(*ps, 1); // no warning
36 new A2(1, &ps); // no warning
38 // Tests to ensure that leaks are reported for consumed news no matter what the arguments are.
39 A2 *a2p1 = new A2; // expected-warning@+1 {{Potential leak of memory}}
40 A2 *a2p2 = new A2(ps); // expected-warning@+1 {{Potential leak of memory}}
41 A2 *a2p3 = new A2(*ps, 1); // expected-warning@+1 {{Potential leak of memory}}
42 A2 *a2p4 = new A2(1, &ps); // expected-warning@+1 {{Potential leak of memory}}