diff options
author | Eric Fiselier <eric@efcs.ca> | 2015-05-01 01:49:37 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2015-05-01 01:49:37 +0000 |
commit | 65ace9daa36051aeeb8140bce8e154c61374938f (patch) | |
tree | 159b25b6309f408bec8c6e218e98bb5cd0e60e05 /libcxxabi/src | |
parent | f43d8e1cce7a5bfd4e464ea83647b4b13c8154ad (diff) | |
download | bcm5719-llvm-65ace9daa36051aeeb8140bce8e154c61374938f.tar.gz bcm5719-llvm-65ace9daa36051aeeb8140bce8e154c61374938f.zip |
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
llvm-svn: 236299
Diffstat (limited to 'libcxxabi/src')
-rw-r--r-- | libcxxabi/src/private_typeinfo.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/libcxxabi/src/private_typeinfo.cpp b/libcxxabi/src/private_typeinfo.cpp index 27aa704896e..beacd701d51 100644 --- a/libcxxabi/src/private_typeinfo.cpp +++ b/libcxxabi/src/private_typeinfo.cpp @@ -387,9 +387,13 @@ __pointer_type_info::can_catch(const __shim_type_info* thrown_type, if (is_equal(__pointee, thrown_pointer_type->__pointee, false)) return true; // bullet 3A - if (is_equal(__pointee, &typeid(void), false)) - return true; - + if (is_equal(__pointee, &typeid(void), false)) { + // pointers to functions cannot be converted to void*. + // pointers to member functions are not handled here. + const __function_type_info* thrown_function = + dynamic_cast<const __function_type_info*>(thrown_pointer_type->__pointee); + return (thrown_function == nullptr); + } // Handle pointer to pointer const __pointer_type_info* nested_pointer_type = dynamic_cast<const __pointer_type_info*>(__pointee); |