diff options
author | John McCall <rjmccall@apple.com> | 2015-09-29 23:55:17 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2015-09-29 23:55:17 +0000 |
commit | 53dcf94d0593a79b661ae8bb85a9155181b1fc41 (patch) | |
tree | ed22c2226ce719084bebf038ad0c6c995b6013b3 /clang/test/CodeGenCXX/exceptions.cpp | |
parent | c1db67e218ae22ab626ba75a5f6329786ca84c63 (diff) | |
download | bcm5719-llvm-53dcf94d0593a79b661ae8bb85a9155181b1fc41.tar.gz bcm5719-llvm-53dcf94d0593a79b661ae8bb85a9155181b1fc41.zip |
Don't crash when a reserved global placement operator new is paired
with a non-reserved operator delete in a new-expression.
llvm-svn: 248862
Diffstat (limited to 'clang/test/CodeGenCXX/exceptions.cpp')
-rw-r--r-- | clang/test/CodeGenCXX/exceptions.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/clang/test/CodeGenCXX/exceptions.cpp b/clang/test/CodeGenCXX/exceptions.cpp index d6b5942dd23..ff76b11350d 100644 --- a/clang/test/CodeGenCXX/exceptions.cpp +++ b/clang/test/CodeGenCXX/exceptions.cpp @@ -2,6 +2,9 @@ typedef __typeof(sizeof(0)) size_t; +// Declare the reserved global placement new. +void *operator new(size_t, void*); + // This just shouldn't crash. namespace test0 { struct allocator { @@ -526,4 +529,21 @@ namespace test11 { // (After this is a terminate landingpad.) } +namespace test12 { + struct A { + void operator delete(void *, void *); + A(); + }; + + A *test(void *ptr) { + return new (ptr) A(); + } + // CHECK-LABEL: define {{.*}} @_ZN6test124testEPv( + // CHECK: [[PTR:%.*]] = load i8*, i8* + // CHECK-NEXT: [[CAST:%.*]] = bitcast i8* [[PTR]] to [[A:%.*]]* + // CHECK-NEXT: invoke void @_ZN6test121AC1Ev([[A]]* [[CAST]]) + // CHECK: ret [[A]]* [[CAST]] + // CHECK: invoke void @_ZN6test121AdlEPvS1_(i8* [[PTR]], i8* [[PTR]]) +} + // CHECK: attributes [[NI_NR_NUW]] = { noinline noreturn nounwind } |