blob: 74b4872371e8904b1a223121f4e99831da4d6685 [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
Louis Dionne8c611142020-04-17 10:29:15 -040014// UNSUPPORTED: no-exceptions
Eric Fiselier3f7c2072016-01-20 04:06:46 +000015
Howard Hinnant26ffb642012-02-01 19:21:28 +000016#include <cassert>
17
Louis Dionne504bc072020-10-08 13:36:33 -040018int main(int, char**)
Howard Hinnant26ffb642012-02-01 19:21:28 +000019{
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 Dionne504bc072020-10-08 13:36:33 -040034
35 return 0;
Howard Hinnant26ffb642012-02-01 19:21:28 +000036}