mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-24 17:06:07 +00:00
Quash TODO regarding catch by array type. Add tests to back it up.
llvm-svn: 149527
This commit is contained in:
parent
af066bbb1f
commit
26ffb64177
@ -238,7 +238,10 @@ bool
|
||||
__array_type_info::can_catch(const __shim_type_info* thrown_type,
|
||||
void*&) const
|
||||
{
|
||||
// TODO: Can this be called?
|
||||
// We can get here if someone tries to catch an array by reference.
|
||||
// However if someone tries to throw an array, it immediately gets
|
||||
// converted to a pointer, which will not convert back to an array
|
||||
// at the catch clause. So this can never catch anything.
|
||||
return false;
|
||||
}
|
||||
|
||||
|
30
libcxxabi/test/catch_array_01.cpp
Normal file
30
libcxxabi/test/catch_array_01.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
//===---------------------- catch_array_01.cpp ----------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// Can you have a catch clause of array type that catches anything?
|
||||
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef char Array[4];
|
||||
Array a = {'H', 'i', '!', 0};
|
||||
try
|
||||
{
|
||||
throw a; // converts to char*
|
||||
assert(false);
|
||||
}
|
||||
catch (Array& b) // can't catch char*
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
}
|
30
libcxxabi/test/catch_array_02.cpp
Normal file
30
libcxxabi/test/catch_array_02.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
//===---------------------- catch_array_02.cpp ----------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// Can you have a catch clause of array type that catches anything?
|
||||
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef char Array[4];
|
||||
Array a = {'H', 'i', '!', 0};
|
||||
try
|
||||
{
|
||||
throw a; // converts to char*
|
||||
assert(false);
|
||||
}
|
||||
catch (Array b) // equivalent to char*
|
||||
{
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user