annotate libcxxabi/test/test_aux_runtime_op_array_new.pass.cpp @ 181:df311c476dd5

CreateIdentifierInfo in ParseCbC (not yet worked)
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 31 May 2020 12:30:11 +0900
parents 0572611fdcc8
children 2e18cbf3894f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 //===-------------------------- test_aux_runtime_op_array_new.cpp ---------===//
anatofuz
parents:
diff changeset
2 //
anatofuz
parents:
diff changeset
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
anatofuz
parents:
diff changeset
4 // See https://llvm.org/LICENSE.txt for license information.
anatofuz
parents:
diff changeset
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
anatofuz
parents:
diff changeset
6 //
anatofuz
parents:
diff changeset
7 //===----------------------------------------------------------------------===//
anatofuz
parents:
diff changeset
8
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
9 // UNSUPPORTED: no-exceptions
150
anatofuz
parents:
diff changeset
10
anatofuz
parents:
diff changeset
11 #include <iostream>
anatofuz
parents:
diff changeset
12 #include <cxxabi.h>
anatofuz
parents:
diff changeset
13
anatofuz
parents:
diff changeset
14 // If the expression passed to operator new[] would result in an overflow, the
anatofuz
parents:
diff changeset
15 // allocation function is not called, and a std::bad_array_new_length exception
anatofuz
parents:
diff changeset
16 // is thrown instead (5.3.4p7).
anatofuz
parents:
diff changeset
17 bool bad_array_new_length_test() {
anatofuz
parents:
diff changeset
18 try {
anatofuz
parents:
diff changeset
19 // We test this directly because Clang does not currently codegen the
anatofuz
parents:
diff changeset
20 // correct call to __cxa_bad_array_new_length, so this test would result
anatofuz
parents:
diff changeset
21 // in passing -1 to ::operator new[], which would then throw a
anatofuz
parents:
diff changeset
22 // std::bad_alloc, causing the test to fail.
anatofuz
parents:
diff changeset
23 __cxxabiv1::__cxa_throw_bad_array_new_length();
anatofuz
parents:
diff changeset
24 } catch ( const std::bad_array_new_length &banl ) {
anatofuz
parents:
diff changeset
25 return true;
anatofuz
parents:
diff changeset
26 }
anatofuz
parents:
diff changeset
27 return false;
anatofuz
parents:
diff changeset
28 }
anatofuz
parents:
diff changeset
29
anatofuz
parents:
diff changeset
30 int main() {
anatofuz
parents:
diff changeset
31 int ret_val = 0;
anatofuz
parents:
diff changeset
32
anatofuz
parents:
diff changeset
33 if ( !bad_array_new_length_test ()) {
anatofuz
parents:
diff changeset
34 std::cerr << "Bad array new length test failed!" << std::endl;
anatofuz
parents:
diff changeset
35 ret_val = 1;
anatofuz
parents:
diff changeset
36 }
anatofuz
parents:
diff changeset
37
anatofuz
parents:
diff changeset
38 return ret_val;
anatofuz
parents:
diff changeset
39 }