mirror of
https://github.com/holub/mame
synced 2025-04-22 16:31:49 +03:00
Fix GCC6 warnings
This commit is contained in:
parent
2300f99311
commit
523b8d1de8
@ -316,7 +316,6 @@ void ADDRESS_MAP_NAME(_name)(address_map &map, device_t &device) \
|
||||
typedef write##_bits##_delegate write_delegate ATTR_UNUSED; \
|
||||
address_map_entry##_bits *curentry = nullptr; \
|
||||
(void)curentry; \
|
||||
assert(&device != nullptr); \
|
||||
map.configure(_space, _bits); \
|
||||
typedef _class drivdata_class ATTR_UNUSED;
|
||||
#define DEVICE_ADDRESS_MAP_START(_name, _bits, _class) \
|
||||
@ -326,7 +325,6 @@ void _class :: _name(::address_map &map, device_t &device) \
|
||||
typedef write##_bits##_delegate write_delegate ATTR_UNUSED; \
|
||||
address_map_entry##_bits *curentry = nullptr; \
|
||||
(void)curentry; \
|
||||
assert(&device != nullptr); \
|
||||
map.configure(AS_PROGRAM, _bits); \
|
||||
typedef _class drivdata_class ATTR_UNUSED;
|
||||
#define ADDRESS_MAP_END \
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
// standard C++ includes
|
||||
#include <exception>
|
||||
#include <type_traits>
|
||||
#include <typeinfo>
|
||||
|
||||
// core system includes
|
||||
@ -312,48 +313,41 @@ class device_t;
|
||||
void report_bad_cast(const std::type_info &src_type, const std::type_info &dst_type);
|
||||
void report_bad_device_cast(const device_t *dev, const std::type_info &src_type, const std::type_info &dst_type);
|
||||
|
||||
// template function for casting from a base class to a derived class that is checked
|
||||
// in debug builds and fast in release builds
|
||||
template<class _Dest, class _Source>
|
||||
inline _Dest downcast(_Source *src)
|
||||
template <typename Dest, typename Source>
|
||||
inline std::enable_if_t<std::is_base_of<device_t, Source>::value> report_bad_cast(Source *const src)
|
||||
{
|
||||
#if defined(MAME_DEBUG) && !defined(MAME_DEBUG_FAST)
|
||||
try {
|
||||
if (dynamic_cast<_Dest>(src) != src)
|
||||
{
|
||||
if (dynamic_cast<const device_t *>(src) != nullptr)
|
||||
report_bad_device_cast(dynamic_cast<const device_t *>(src), typeid(src), typeid(_Dest));
|
||||
else
|
||||
report_bad_cast(typeid(src), typeid(_Dest));
|
||||
}
|
||||
}
|
||||
catch (std::bad_cast &)
|
||||
{
|
||||
report_bad_cast(typeid(src), typeid(_Dest));
|
||||
}
|
||||
#endif
|
||||
return static_cast<_Dest>(src);
|
||||
if (src) report_bad_device_cast(src, typeid(Source), typeid(Dest));
|
||||
else report_bad_cast(typeid(Source), typeid(Dest));
|
||||
}
|
||||
|
||||
template<class _Dest, class _Source>
|
||||
inline _Dest downcast(_Source &src)
|
||||
template <typename Dest, typename Source>
|
||||
inline std::enable_if_t<!std::is_base_of<device_t, Source>::value> report_bad_cast(Source *const src)
|
||||
{
|
||||
device_t const *dev(dynamic_cast<device_t const *>(src));
|
||||
if (dev) report_bad_device_cast(dev, typeid(Source), typeid(Dest));
|
||||
else report_bad_cast(typeid(Source), typeid(Dest));
|
||||
}
|
||||
|
||||
// template function for casting from a base class to a derived class that is checked
|
||||
// in debug builds and fast in release builds
|
||||
template <typename Dest, typename Source>
|
||||
inline Dest downcast(Source *src)
|
||||
{
|
||||
#if defined(MAME_DEBUG) && !defined(MAME_DEBUG_FAST)
|
||||
try {
|
||||
if (&dynamic_cast<_Dest>(src) != &src)
|
||||
{
|
||||
if (dynamic_cast<const device_t *>(&src) != nullptr)
|
||||
report_bad_device_cast(dynamic_cast<const device_t *>(&src), typeid(src), typeid(_Dest));
|
||||
else
|
||||
report_bad_cast(typeid(src), typeid(_Dest));
|
||||
}
|
||||
}
|
||||
catch (std::bad_cast &)
|
||||
{
|
||||
report_bad_cast(typeid(src), typeid(_Dest));
|
||||
}
|
||||
Dest const chk(dynamic_cast<Dest>(src));
|
||||
if (!chk || (chk != src)) report_bad_cast<std::remove_pointer_t<Dest>, Source>(src);
|
||||
#endif
|
||||
return static_cast<_Dest>(src);
|
||||
return static_cast<Dest>(src);
|
||||
}
|
||||
|
||||
template<class Dest, class Source>
|
||||
inline Dest downcast(Source &src)
|
||||
{
|
||||
#if defined(MAME_DEBUG) && !defined(MAME_DEBUG_FAST)
|
||||
std::remove_reference_t<Dest> *const chk(dynamic_cast<std::remove_reference_t<Dest> *>(&src));
|
||||
if (!chk || (chk != &src)) report_bad_cast<std::remove_reference_t<Dest>, Source>(&src);
|
||||
#endif
|
||||
return static_cast<Dest>(src);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user