[AMDGPU][AsmParser][NFC] Get rid of custom default operand handlers.
[llvm-project.git] / clang / test / Analysis / cxx-inherited-ctor-init-expr.cpp
blob8370ebfbde09b89364f3a0ffa70030257840a1a4
1 // RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s
3 void clang_analyzer_eval(bool);
5 namespace basic_tests {
6 struct A {
7 int x;
8 A(int x): x(x) {}
9 };
11 struct B : A {
12 using A::A;
15 struct C : B {
16 using B::B;
19 void test_B() {
20 B b(1);
21 clang_analyzer_eval(b.x == 1); // expected-warning{{TRUE}}
24 void test_C() {
25 C c(2);
26 clang_analyzer_eval(c.x == 2); // expected-warning{{TRUE}}
28 } // namespace basic_tests
30 namespace arguments_with_constructors {
31 struct S {
32 int x, y;
33 S(int x, int y): x(x), y(y) {}
34 ~S() {}
37 struct A {
38 S s;
39 int z;
40 A(S s, int z) : s(s), z(z) {}
43 struct B : A {
44 using A::A;
47 void test_B() {
48 B b(S(1, 2), 3);
49 // FIXME: There should be no execution path on which this is false.
50 clang_analyzer_eval(b.s.x == 1); // expected-warning{{TRUE}}
51 // expected-warning@-1{{FALSE}}
53 // FIXME: There should be no execution path on which this is false.
54 clang_analyzer_eval(b.s.y == 2); // expected-warning{{TRUE}}
55 // expected-warning@-1{{FALSE}}
57 clang_analyzer_eval(b.z == 3); // expected-warning{{TRUE}}
59 } // namespace arguments_with_constructors
61 namespace inherited_constructor_crash {
62 class a {
63 public:
64 a(int);
66 struct b : a {
67 using a::a; // Ihnerited ctor.
69 void c() {
70 int d;
71 // This construct expr utilizes the inherited ctor.
72 // Note that d must be uninitialized to cause the crash.
73 (b(d)); // expected-warning{{1st function call argument is an uninitialized value}}
75 } // namespace inherited_constructor_crash