Skip to content

Commit ea8260b

Browse files
committed
add escape templated function, guard enum list initialization for >= C++17
1 parent 959866a commit ea8260b

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

clang/test/Analysis/initializer.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,9 @@ void foo() {
255255
} // namespace CXX17_aggregate_construction
256256

257257
namespace newexpr_init_list_initialization {
258+
template <class FirstT, class... Rest>
259+
void escape(FirstT first, Rest... args);
260+
258261
struct S {
259262
int foo;
260263
int bar;
@@ -330,14 +333,16 @@ void considered_fields_initd() {
330333
delete S;
331334
}
332335

336+
#if __cplusplus >= 201703L
333337
enum Enum : int {
334338
};
335339
// FIXME: uncomment when CSA supports list init of enums
336340
void list_init_enum() {
337-
// Enum *E = new Enum{53};
338-
// clang_analyzer_eval(53 == *E); // should be TRUE
339-
// delete E;
341+
Enum *E = new Enum{53};
342+
clang_analyzer_eval(53 == *E); // expected-warning{{TRUE}}
343+
delete E;
340344
}
345+
#endif // __cplusplus >= 201703L
341346

342347
class PubClass {
343348
public:
@@ -437,14 +442,7 @@ void nested_aggregates() {
437442
clang_analyzer_eval(2 == N7->inner.bar); // expected-warning{{TRUE}}
438443
clang_analyzer_eval(3 == N7->baz); // expected-warning{{TRUE}}
439444

440-
delete N;
441-
delete N1;
442-
delete N2;
443-
delete N3;
444-
delete N4;
445-
delete N5;
446-
delete N6;
447-
delete N7;
445+
escape(N,N1,N2,N3,N4,N5,N6,N7);
448446
}
449447
} // namespace newexpr_init_list_initialization
450448

0 commit comments

Comments
 (0)