Howard Hinnant | 26ffb64 | 2012-02-01 19:21:28 +0000 | [diff] [blame] | 1 | //===---------------------- catch_array_01.cpp ----------------------------===// |
| 2 | // |
Chandler Carruth | 57b08b0 | 2019-01-19 10:56:40 +0000 | [diff] [blame] | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
Howard Hinnant | 26ffb64 | 2012-02-01 19:21:28 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | // Can you have a catch clause of array type that catches anything? |
| 10 | |
Eric Fiselier | 3f7c207 | 2016-01-20 04:06:46 +0000 | [diff] [blame] | 11 | // GCC incorrectly allows array types to be caught by reference. |
| 12 | // See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69372 |
| 13 | // XFAIL: gcc |
Louis Dionne | 8c61114 | 2020-04-17 10:29:15 -0400 | [diff] [blame] | 14 | // UNSUPPORTED: no-exceptions |
Eric Fiselier | 3f7c207 | 2016-01-20 04:06:46 +0000 | [diff] [blame] | 15 | |
Howard Hinnant | 26ffb64 | 2012-02-01 19:21:28 +0000 | [diff] [blame] | 16 | #include <cassert> |
| 17 | |
Louis Dionne | 504bc07 | 2020-10-08 13:36:33 -0400 | [diff] [blame] | 18 | int main(int, char**) |
Howard Hinnant | 26ffb64 | 2012-02-01 19:21:28 +0000 | [diff] [blame] | 19 | { |
| 20 | typedef char Array[4]; |
| 21 | Array a = {'H', 'i', '!', 0}; |
| 22 | try |
| 23 | { |
| 24 | throw a; // converts to char* |
| 25 | assert(false); |
| 26 | } |
| 27 | catch (Array& b) // can't catch char* |
| 28 | { |
| 29 | assert(false); |
| 30 | } |
| 31 | catch (...) |
| 32 | { |
| 33 | } |
Louis Dionne | 504bc07 | 2020-10-08 13:36:33 -0400 | [diff] [blame] | 34 | |
| 35 | return 0; |
Howard Hinnant | 26ffb64 | 2012-02-01 19:21:28 +0000 | [diff] [blame] | 36 | } |