| 1 |
// RUN: %clang_analyze_cc1 -w -analyzer-checker=core -analyzer-output=text \ |
| 2 |
// RUN: -verify %s |
| 3 |
|
| 4 |
namespace note_on_skipped_vbases { |
| 5 |
struct 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 |
|
| 11 |
struct 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 but |
| 15 |
// it doesn't appear because it's pruned out because it's irrelevant to the |
| 16 |
// 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 |
|
| 24 |
struct 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 |
|
| 31 |
void test_note() { |
| 32 |
C c; // expected-note{{Calling default constructor for 'C'}} |
| 33 |
} |
| 34 |
|
| 35 |
struct D: B { |
| 36 |
D() : A(1), B() {} |
| 37 |
}; |
| 38 |
|
| 39 |
void 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_vbases |