File tree Expand file tree Collapse file tree 3 files changed +39
-25
lines changed Expand file tree Collapse file tree 3 files changed +39
-25
lines changed Original file line number Diff line number Diff line change @@ -457,7 +457,7 @@ namespace optional_union {
457457 unique_ptr<int > present;
458458 char notpresent;
459459 custom_union_t () : present (unique_ptr<int >()) {}
460- ~custom_union_t () {};
460+ ~custom_union_t () {}
461461 };
462462
463463 void testUnionCorrect () {
Original file line number Diff line number Diff line change @@ -377,27 +377,3 @@ void directUnknownSymbol() {
377377}
378378
379379}
380-
381- void testUnionDtor () {
382- static int unionDtorCalled;
383- InlineDtor::cnt = 0 ;
384- InlineDtor::dtorCalled = 0 ;
385- unionDtorCalled = 0 ;
386- {
387- union UnionDtor {
388- InlineDtor kind1;
389- char kind2;
390- ~UnionDtor () { unionDtorCalled++; }
391- };
392- UnionDtor u1{.kind1 {}};
393- UnionDtor u2{.kind2 {}};
394- auto u3 = new UnionDtor{.kind1 {}};
395- auto u4 = new UnionDtor{.kind2 {}};
396- delete u3;
397- delete u4;
398- }
399-
400- clang_analyzer_eval (unionDtorCalled == 4 ); // expected-warning {{TRUE}}
401- clang_analyzer_eval (InlineDtor::dtorCalled != 4 ); // expected-warning {{TRUE}}
402- clang_analyzer_eval (InlineDtor::dtorCalled == 0 ); // expected-warning {{TRUE}}
403- }
Original file line number Diff line number Diff line change 1+ // RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config c++-inlining=destructors -verify -std=c++11 %s
2+ // RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config c++-inlining=destructors -verify -std=c++17 %s
3+
4+ void clang_analyzer_eval (bool );
5+
6+ struct InlineDtor {
7+ static int cnt;
8+ static int dtorCalled;
9+ ~InlineDtor () {
10+ ++dtorCalled;
11+ }
12+ };
13+
14+ int InlineDtor::cnt = 0 ;
15+ int InlineDtor::dtorCalled = 0 ;
16+
17+ void testUnionDtor () {
18+ static int unionDtorCalled;
19+ InlineDtor::cnt = 0 ;
20+ InlineDtor::dtorCalled = 0 ;
21+ unionDtorCalled = 0 ;
22+ {
23+ union UnionDtor {
24+ InlineDtor kind1;
25+ char kind2;
26+ ~UnionDtor () { unionDtorCalled++; }
27+ };
28+ UnionDtor u1{.kind1 {}};
29+ UnionDtor u2{.kind2 {}};
30+ auto u3 = new UnionDtor{.kind1 {}};
31+ auto u4 = new UnionDtor{.kind2 {}};
32+ delete u3;
33+ delete u4;
34+ }
35+
36+ clang_analyzer_eval (unionDtorCalled == 4 ); // expected-warning {{TRUE}}
37+ clang_analyzer_eval (InlineDtor::dtorCalled == 0 ); // expected-warning {{TRUE}}
38+ }
You can’t perform that action at this time.
0 commit comments