1*eb8650a7SLouis Dionne //===----------------------------------------------------------------------===//
2e434b34fSJonathan Roelofs //
357b08b09SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
457b08b09SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
557b08b09SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6e434b34fSJonathan Roelofs //
7e434b34fSJonathan Roelofs //===----------------------------------------------------------------------===//
8e434b34fSJonathan Roelofs 
9e434b34fSJonathan Roelofs // Can you have a catch clause of array type that catches anything?
10e434b34fSJonathan Roelofs 
113f7c2074SEric Fiselier // GCC incorrectly allows function pointer to be caught by reference.
123f7c2074SEric Fiselier // See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69372
133f7c2074SEric Fiselier // XFAIL: gcc
148c61114cSLouis Dionne // UNSUPPORTED: no-exceptions
153f7c2074SEric Fiselier 
1660ba1fefSLouis Dionne // 65ace9daa360 made it in the dylib in macOS 10.11
17c360553cSLouis Dionne // XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10}}
1860ba1fefSLouis Dionne 
19e434b34fSJonathan Roelofs #include <cassert>
20e434b34fSJonathan Roelofs 
2165ace9daSEric Fiselier template <class Tp>
can_convert(Tp)2265ace9daSEric Fiselier bool can_convert(Tp) { return true; }
2365ace9daSEric Fiselier 
2465ace9daSEric Fiselier template <class>
can_convert(...)2565ace9daSEric Fiselier bool can_convert(...) { return false; }
2665ace9daSEric Fiselier 
f()27e434b34fSJonathan Roelofs void f() {}
28e434b34fSJonathan Roelofs 
main(int,char **)29504bc07dSLouis Dionne int main(int, char**)
30e434b34fSJonathan Roelofs {
31e434b34fSJonathan Roelofs     typedef void Function();
3265ace9daSEric Fiselier     assert(!can_convert<Function&>(&f));
3365ace9daSEric Fiselier     assert(!can_convert<void*>(&f));
34e434b34fSJonathan Roelofs     try
35e434b34fSJonathan Roelofs     {
36e434b34fSJonathan Roelofs         throw f;     // converts to void (*)()
37e434b34fSJonathan Roelofs         assert(false);
38e434b34fSJonathan Roelofs     }
39e434b34fSJonathan Roelofs     catch (Function& b)  // can't catch void (*)()
40e434b34fSJonathan Roelofs     {
41e434b34fSJonathan Roelofs         assert(false);
42e434b34fSJonathan Roelofs     }
4365ace9daSEric Fiselier     catch (void*) // can't catch as void*
4465ace9daSEric Fiselier     {
4565ace9daSEric Fiselier         assert(false);
4665ace9daSEric Fiselier     }
4765ace9daSEric Fiselier     catch(Function*)
4865ace9daSEric Fiselier     {
4965ace9daSEric Fiselier     }
50e434b34fSJonathan Roelofs     catch (...)
51e434b34fSJonathan Roelofs     {
5265ace9daSEric Fiselier         assert(false);
53e434b34fSJonathan Roelofs     }
54504bc07dSLouis Dionne 
55504bc07dSLouis Dionne     return 0;
56e434b34fSJonathan Roelofs }
57