blob: 03288e7da47a607db246547ec581f2be36aa400f [file] [log] [blame]
Howard Hinnant26ffb642012-02-01 19:21:28 +00001//===---------------------- catch_array_01.cpp ----------------------------===//
2//
Chandler Carruth57b08b02019-01-19 10:56:40 +00003// 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 Hinnant26ffb642012-02-01 19:21:28 +00006//
7//===----------------------------------------------------------------------===//
8
9// Can you have a catch clause of array type that catches anything?
10
Eric Fiselier3f7c2072016-01-20 04:06:46 +000011// 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
Asiri Rathnayake57e446d2016-05-31 12:01:32 +000014// UNSUPPORTED: libcxxabi-no-exceptions
Eric Fiselier3f7c2072016-01-20 04:06:46 +000015
Howard Hinnant26ffb642012-02-01 19:21:28 +000016#include <cassert>
17
18int main()
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 }
34}