summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenCXX/exceptions.cpp
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2011-09-06 18:53:03 +0000
committerEli Friedman <eli.friedman@gmail.com>2011-09-06 18:53:03 +0000
commitcf9b1f6524436866cf5f8639193ebe89d92ae6b0 (patch)
tree3e09244181e0f424213b9691c386e04a4f83a52d /clang/test/CodeGenCXX/exceptions.cpp
parent0b758ed6ba35c9d5be7967df6b6fc7ff4c8dc1d5 (diff)
downloadbcm5719-llvm-cf9b1f6524436866cf5f8639193ebe89d92ae6b0.tar.gz
bcm5719-llvm-cf9b1f6524436866cf5f8639193ebe89d92ae6b0.zip
Rearrange code so that we pass the right pointer to delete[] when an exception is thrown constructing the array elements in an array new expression. Fixes PR10870.
llvm-svn: 139158
Diffstat (limited to 'clang/test/CodeGenCXX/exceptions.cpp')
-rw-r--r--clang/test/CodeGenCXX/exceptions.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/clang/test/CodeGenCXX/exceptions.cpp b/clang/test/CodeGenCXX/exceptions.cpp
index 18a3d108dd3..0fbb09c2624 100644
--- a/clang/test/CodeGenCXX/exceptions.cpp
+++ b/clang/test/CodeGenCXX/exceptions.cpp
@@ -406,4 +406,22 @@ namespace test8 {
void test() {
throw makeA();
}
+ // CHECK: define void @_ZN5test84testEv
+}
+
+// Make sure we generate the correct code for the delete[] call which
+// happens if A::A() throws. (We were previously calling delete[] on
+// a pointer to the first array element, not the pointer returned by new[].)
+// PR10870
+namespace test9 {
+ struct A {
+ A();
+ ~A();
+ };
+ A* test() {
+ return new A[10];
+ }
+ // CHECK: define {{%.*}}* @_ZN5test94testEv
+ // CHECK: [[TEST9_NEW:%.*]] = call noalias i8* @_Znam
+ // CHECK: call void @_ZdaPv(i8* [[TEST9_NEW]])
}
OpenPOWER on IntegriCloud