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.
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.
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);
20 class Derived
: public Base
{
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
{
37 Base(int x
) : foox(x
) {}
40 class Derived
: public Base
{
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
{
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