Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Analysis / issue-70464.cpp
blobf3b3072eb91982368096e237880745a9ec379fd5
1 // RUN: %clang_analyze_cc1 %s -verify -analyzer-checker=core,debug.ExprInspection
3 // Refer to https://github.com/llvm/llvm-project/issues/70464 for more details.
4 //
5 // When the base class does not have a declared constructor, the base
6 // initializer in the constructor of the derived class should use the given
7 // initializer list to finish the initialization of the base class.
8 //
9 // Also testing base constructor and delegate constructor to make sure this
10 // change will not break these two cases when a CXXConstructExpr is available.
12 void clang_analyzer_dump(int);
14 namespace init_list {
16 struct Base {
17 int foox;
20 class Derived : public Base {
21 public:
22 Derived() : Base{42} {
23 // The dereference to this->foox below should be initialized properly.
24 clang_analyzer_dump(this->foox); // expected-warning{{42 S32b}}
25 clang_analyzer_dump(foox); // expected-warning{{42 S32b}}
29 void entry() { Derived test; }
31 } // namespace init_list
33 namespace base_ctor_call {
35 struct Base {
36 int foox;
37 Base(int x) : foox(x) {}
40 class Derived : public Base {
41 public:
42 Derived() : Base{42} {
43 clang_analyzer_dump(this->foox); // expected-warning{{42 S32b}}
44 clang_analyzer_dump(foox); // expected-warning{{42 S32b}}
48 void entry() { Derived test; }
50 } // namespace base_ctor_call
52 namespace delegate_ctor_call {
54 struct Base {
55 int foox;
58 struct Derived : Base {
59 Derived(int parx) { this->foox = parx; }
60 Derived() : Derived{42} {
61 clang_analyzer_dump(this->foox); // expected-warning{{42 S32b}}
62 clang_analyzer_dump(foox); // expected-warning{{42 S32b}}
66 void entry() { Derived test; }
68 } // namespace delegate_ctor_call