brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · db744ef Raw
45 lines · cpp
1// RUN: %clang_analyze_cc1 -w -analyzer-checker=core -analyzer-output=text \2// RUN:   -verify %s3 4namespace note_on_skipped_vbases {5struct A {6  int x;7  A() : x(0) {} // expected-note{{The value 0 is assigned to 'c.x'}}8  A(int x) : x(x) {}9};10 11struct B : virtual A {12  int y;13  // This note appears only once, when this constructor is called from C.14  // When this constructor is called from D, this note is still correct but15  // it doesn't appear because it's pruned out because it's irrelevant to the16  // bug report.17  B(): // expected-note{{Virtual base initialization skipped because it has already been handled by the most derived class}}18    A(1),19    y(1 / x) // expected-warning{{Division by zero}}20             // expected-note@-1{{Division by zero}}21  {}22};23 24struct C : B {25  C(): // expected-note{{Calling default constructor for 'A'}}26       // expected-note@-1{{Returning from default constructor for 'A'}}27    B() // expected-note{{Calling default constructor for 'B'}}28  {}29};30 31void test_note() {32  C c; // expected-note{{Calling default constructor for 'C'}}33}34 35struct D: B {36  D() : A(1), B() {}37};38 39void test_prunability() {40  D d;41  1 / 0; // expected-warning{{Division by zero}}42         // expected-note@-1{{Division by zero}}43}44} // namespace note_on_skipped_vbases45