Skip to content

Commit e14945b

Browse files
committed
Add placement new list initializer argument tests
1 parent 0a9bc4c commit e14945b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

clang/test/Analysis/initializer.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,25 @@ void nested_aggregates() {
445445
}
446446
} // namespace newexpr_init_list_initialization
447447

448+
namespace initializer_list_arg {
449+
struct S {
450+
int x;
451+
};
452+
void aggregate_struct() {
453+
S s;
454+
::new (&s) S{1};
455+
clang_analyzer_eval(1 == s.x); // expected-warning{{TRUE}}
456+
457+
S vi;
458+
::new (&vi) S{};
459+
clang_analyzer_eval(0 == vi.x); // expected-warning{{TRUE}}
460+
461+
S di;
462+
::new (&di) S;
463+
int z = di.x + 1; // expected-warning{{The left operand of '+' is a garbage value}}
464+
}
465+
} // namespace initializer_list_arg
466+
448467
namespace CXX17_transparent_init_list_exprs {
449468
class A {};
450469

0 commit comments

Comments
 (0)