aboutsummaryrefslogtreecommitdiff
path: root/clang/test/AST/ByteCode/placement-new.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test/AST/ByteCode/placement-new.cpp')
-rw-r--r--clang/test/AST/ByteCode/placement-new.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/clang/test/AST/ByteCode/placement-new.cpp b/clang/test/AST/ByteCode/placement-new.cpp
index b587cd6..1c015da 100644
--- a/clang/test/AST/ByteCode/placement-new.cpp
+++ b/clang/test/AST/ByteCode/placement-new.cpp
@@ -494,3 +494,32 @@ constexpr int modify_const_variable() {
}
static_assert(modify_const_variable()); // both-error {{not an integral constant expression}} \
// both-note {{in call to}}
+
+constexpr int nullDest() {
+ new (nullptr) int{12}; // both-note {{construction of dereferenced null pointer}}
+ return 0;
+}
+static_assert(nullDest() == 0); // both-error {{not an integral constant expression}} \
+ // both-note {{in call to}}
+
+constexpr int nullArrayDest() {
+ new (nullptr) int{12}; // both-note {{construction of dereferenced null pointer}}
+ return 0;
+}
+static_assert(nullArrayDest() == 0); // both-error {{not an integral constant expression}} \
+ // both-note {{in call to}}
+
+constexpr int intDest() {
+ new ((void*)2) int{3}; // both-note {{cast that performs the conversions of a reinterpret_cast}}
+ return 0;
+}
+static_assert(intDest() == 0); // both-error {{not an integral constant expression}} \
+ // both-note {{in call to}}
+
+constexpr int intDestArray() {
+ new ((void*)2) int[4]; // both-note {{cast that performs the conversions of a reinterpret_cast}}
+ return 0;
+}
+static_assert(intDestArray() == 0); // both-error {{not an integral constant expression}} \
+ // both-note {{in call to}}
+