summaryrefslogtreecommitdiff
path: root/test/catch_function_01.pass.cpp
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2015-05-01 01:49:37 +0000
committerEric Fiselier <eric@efcs.ca>2015-05-01 01:49:37 +0000
commitb979db159a515fe12b54f793690618313e017259 (patch)
treebfc386d843d3e43f8390b037fa10cb1c9fc7ed5a /test/catch_function_01.pass.cpp
parent36414035c7d64e447c34aaf983d65a47c540b325 (diff)
Disallow conversions from function pointers to void*.
Function pointers and member function pointers cannot be converted to void*. libc++abi incorrectly allows this conversion for function pointers. Review URL: http://reviews.llvm.org/D8811 git-svn-id: https://llvm.org/svn/llvm-project/libcxxabi/trunk@236299 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/catch_function_01.pass.cpp')
-rw-r--r--test/catch_function_01.pass.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/catch_function_01.pass.cpp b/test/catch_function_01.pass.cpp
index 33999f2..087fce4 100644
--- a/test/catch_function_01.pass.cpp
+++ b/test/catch_function_01.pass.cpp
@@ -11,11 +11,19 @@
#include <cassert>
+template <class Tp>
+bool can_convert(Tp) { return true; }
+
+template <class>
+bool can_convert(...) { return false; }
+
void f() {}
int main()
{
typedef void Function();
+ assert(!can_convert<Function&>(&f));
+ assert(!can_convert<void*>(&f));
try
{
throw f; // converts to void (*)()
@@ -25,7 +33,15 @@ int main()
{
assert(false);
}
+ catch (void*) // can't catch as void*
+ {
+ assert(false);
+ }
+ catch(Function*)
+ {
+ }
catch (...)
{
+ assert(false);
}
}