Home | History | Annotate | Download | only in test
      1 //===---------------------- catch_array_01.cpp ----------------------------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is dual licensed under the MIT and the University of Illinois Open
      6 // Source Licenses. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 
     10 // Can you have a catch clause of array type that catches anything?
     11 
     12 // GCC incorrectly allows array types to be caught by reference.
     13 // See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69372
     14 // XFAIL: gcc
     15 // UNSUPPORTED: libcxxabi-no-exceptions
     16 
     17 #include <cassert>
     18 
     19 int main()
     20 {
     21     typedef char Array[4];
     22     Array a = {'H', 'i', '!', 0};
     23     try
     24     {
     25         throw a;  // converts to char*
     26         assert(false);
     27     }
     28     catch (Array& b)  // can't catch char*
     29     {
     30         assert(false);
     31     }
     32     catch (...)
     33     {
     34     }
     35 }
     36