llvm-project
36 строк · 917.0 Байт
1//===----------------------------------------------------------------------===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8
9// Can you have a catch clause of array type that catches anything?
10
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
14// UNSUPPORTED: no-exceptions
15
16#include <cassert>
17
18int main(int, char**)
19{
20typedef char Array[4];
21Array a = {'H', 'i', '!', 0};
22try
23{
24throw a; // converts to char*
25assert(false);
26}
27catch (Array& b) // can't catch char*
28{
29assert(false);
30}
31catch (...)
32{
33}
34
35return 0;
36}
37