diff options
author | Jonathan Roelofs <jonathan@codesourcery.com> | 2015-01-21 19:05:37 +0000 |
---|---|---|
committer | Jonathan Roelofs <jonathan@codesourcery.com> | 2015-01-21 19:05:37 +0000 |
commit | e434b34fa342da0539581690334b105101d00155 (patch) | |
tree | aac5c35a8c7931251e06f007af33d4182627b1f5 /libcxxabi/test/test_aux_runtime_op_array_new.pass.cpp | |
parent | 311730ac7834eb2d1283c86b6303e688343271bd (diff) | |
download | bcm5719-llvm-e434b34fa342da0539581690334b105101d00155.tar.gz bcm5719-llvm-e434b34fa342da0539581690334b105101d00155.zip |
Rename all of the tests in preparation for merging lit configs with libcxx
http://reviews.llvm.org/D7101
llvm-svn: 226691
Diffstat (limited to 'libcxxabi/test/test_aux_runtime_op_array_new.pass.cpp')
-rw-r--r-- | libcxxabi/test/test_aux_runtime_op_array_new.pass.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/libcxxabi/test/test_aux_runtime_op_array_new.pass.cpp b/libcxxabi/test/test_aux_runtime_op_array_new.pass.cpp new file mode 100644 index 00000000000..8d9f547a315 --- /dev/null +++ b/libcxxabi/test/test_aux_runtime_op_array_new.pass.cpp @@ -0,0 +1,38 @@ +//===-------------------------- test_aux_runtime_op_array_new.cpp ---------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <iostream> +#include <cxxabi.h> + +// If the expression passed to operator new[] would result in an overflow, the +// allocation function is not called, and a std::bad_array_new_length exception +// is thrown instead (5.3.4p7). +bool bad_array_new_length_test() { + try { + // We test this directly because Clang does not currently codegen the + // correct call to __cxa_bad_array_new_length, so this test would result + // in passing -1 to ::operator new[], which would then throw a + // std::bad_alloc, causing the test to fail. + __cxxabiv1::__cxa_throw_bad_array_new_length(); + } catch ( const std::bad_array_new_length &banl ) { + return true; + } + return false; +} + +int main(int argc, char *argv []) { + int ret_val = 0; + + if ( !bad_array_new_length_test ()) { + std::cerr << "Bad array new length test failed!" << std::endl; + ret_val = 1; + } + + return ret_val; +} |