summaryrefslogtreecommitdiffstats
path: root/test/CodeGenCXX/new-array-init.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2019-05-06 03:47:15 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2019-05-06 03:47:15 +0000
commit5b0a110410710c5e5b3a197edced3676c92b6e89 (patch)
tree8a3994ce841efa3aa2dfb291957cdd316053d3a1 /test/CodeGenCXX/new-array-init.cpp
parentf14f7e2753fb69cec95009f4f3b2e3eab14e4f10 (diff)
[c++20] Implement P1009R2: allow omitting the array bound in an array
new expression. This was voted into C++20 as a defect report resolution, so we retroactively apply it to all prior language modes (though it can never actually be used before C++11 mode). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@360006 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGenCXX/new-array-init.cpp')
-rw-r--r--test/CodeGenCXX/new-array-init.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/CodeGenCXX/new-array-init.cpp b/test/CodeGenCXX/new-array-init.cpp
index 90cd600229..b504d5e780 100644
--- a/test/CodeGenCXX/new-array-init.cpp
+++ b/test/CodeGenCXX/new-array-init.cpp
@@ -123,3 +123,25 @@ void constexpr_test() {
// SIO: call i8* @_Zna{{.}}(i32 4)
new int[0+1]{0};
}
+
+// CHECK-LABEL: define void @_Z13unknown_boundv
+void unknown_bound() {
+ struct Aggr { int x, y, z; };
+ new Aggr[]{1, 2, 3, 4};
+ // CHECK: call {{.*}}_Znaj(i32 24)
+ // CHECK: store i32 1
+ // CHECK: store i32 2
+ // CHECK: store i32 3
+ // CHECK: store i32 4
+ // CHECK: store i32 0
+ // CHECK: store i32 0
+ // CHECK-NOT: store
+ // CHECK: }
+}
+
+// CHECK-LABEL: define void @_Z20unknown_bound_stringv
+void unknown_bound_string() {
+ new char[]{"hello"};
+ // CHECK: call {{.*}}_Znaj(i32 6)
+ // CHECK: memcpy{{.*}} i32 6,
+}