Skip to content

Commit 6ec3ea6

Browse files
committed
add tests to cover unsupported cases
1 parent f19ea82 commit 6ec3ea6

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

clang/test/SemaCXX/ms-constexpr-new.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,12 @@ namespace std {
1212
}
1313
}
1414

15-
constexpr bool check_construct_at() { int x; return *std::construct_at(&x, 42) == 42; }
16-
static_assert(check_construct_at());
15+
constexpr bool check_std_construct_at() { int x; return *std::construct_at(&x, 42) == 42; }
16+
static_assert(check_std_construct_at());
17+
18+
constexpr int* construct_at(int* p, int v) { [[msvc::constexpr]] return ::new (p) int(v); } // unsupported-error {{constexpr function never produces a constant expression}} \
19+
// unsupported-warning {{unknown attribute 'constexpr' ignored}} \
20+
// unsupported-note 2{{this placement new expression is not supported in constant expressions before C++2c}}
21+
constexpr bool check_construct_at() { int x; return *construct_at(&x, 42) == 42; } // unsupported-note {{in call to 'construct_at(&x, 42)'}}
22+
static_assert(check_construct_at()); // unsupported-error {{static assertion expression is not an integral constant expression}}\
23+
// unsupported-note {{in call to 'check_construct_at()'}}

0 commit comments

Comments
 (0)