1 // RUN: %clang_analyze_cc1 -analyze -analyzer-checker core -analyzer-config cfg-temporary-dtors=true,c++-temp-dtor-inlining=true -analyzer-output=text -verify %s
3 namespace test_simple_temporary
{
8 C(int x
): x(x
) {} // expected-note{{The value 0 is assigned to field 'x'}}
9 ~C() { x
= 1 / x
; } // expected-warning{{Division by zero}}
10 // expected-note@-1{{Division by zero}}
14 C(0); // expected-note {{Passing the value 0 via 1st parameter 'x'}}
15 // expected-note@-1{{Calling constructor for 'C'}}
16 // expected-note@-2{{Returning from constructor for 'C'}}
17 // expected-note@-3{{Calling '~C'}}
19 } // end namespace test_simple_temporary
21 namespace test_lifetime_extended_temporary
{
26 C(int x
): x(x
) {} // expected-note{{The value 0 is assigned to field 'x'}}
28 ~C() { x
= 1 / x
; } // expected-warning{{Division by zero}}
29 // expected-note@-1{{Division by zero}}
33 // We'd divide by zero in the automatic destructor for variable 'c'.
34 const C
&c
= coin
? C(1) : C(0); // expected-note {{Assuming 'coin' is 0}}
35 // expected-note@-1{{'?' condition is false}}
36 // expected-note@-2{{Passing the value 0 via 1st parameter 'x'}}
37 // expected-note@-3{{Calling constructor for 'C'}}
38 // expected-note@-4{{Returning from constructor for 'C'}}
40 } // expected-note{{Calling '~C'}}
41 } // end namespace test_lifetime_extended_temporary
43 namespace test_bug_after_dtor
{
49 ~C() { glob
-= 2; } // expected-note{{The value 0 is assigned to 'glob'}}
54 C(); // expected-note {{Calling '~C'}}
55 // expected-note@-1{{Returning from '~C'}}
56 glob
= 1 / glob
; // expected-warning{{Division by zero}}
57 // expected-note@-1{{Division by zero}}
59 } // end namespace test_bug_after_dtor