brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · 8370ebf Raw
76 lines · cpp
1// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s2 3void clang_analyzer_eval(bool);4 5namespace basic_tests {6struct A {7  int x;8  A(int x): x(x) {}9};10 11struct B : A {12  using A::A;13};14 15struct C : B {16  using B::B;17};18 19void test_B() {20  B b(1);21  clang_analyzer_eval(b.x == 1); // expected-warning{{TRUE}}22}23 24void test_C() {25  C c(2);26  clang_analyzer_eval(c.x == 2); // expected-warning{{TRUE}}27}28} // namespace basic_tests29 30namespace arguments_with_constructors {31struct S {32  int x, y;33  S(int x, int y): x(x), y(y) {}34  ~S() {}35};36 37struct A {38  S s;39  int z;40  A(S s, int z) : s(s), z(z) {}41};42 43struct B : A {44  using A::A;45};46 47void 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}}52 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}}56 57  clang_analyzer_eval(b.z == 3); // expected-warning{{TRUE}}58}59} // namespace arguments_with_constructors60 61namespace inherited_constructor_crash {62class a {63public:64  a(int);65};66struct b : a {67  using a::a; // Ihnerited ctor.68};69void 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}}74}75} // namespace inherited_constructor_crash76